From 4b0cb640c389843afbf12fe713dbde2f28ce92d1 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 11 Apr 2016 14:09:27 -0700 Subject: [PATCH] Test cases for functions with same name present in the outerscope --- ...dSameNameFunctionDeclarationES5.errors.txt | 37 ++++++++++++++++++ ...ockScopedSameNameFunctionDeclarationES5.js | 35 +++++++++++++++++ ...dSameNameFunctionDeclarationES6.errors.txt | 37 ++++++++++++++++++ ...ockScopedSameNameFunctionDeclarationES6.js | 35 +++++++++++++++++ ...ameFunctionDeclarationStrictES5.errors.txt | 38 +++++++++++++++++++ ...pedSameNameFunctionDeclarationStrictES5.js | 37 ++++++++++++++++++ ...ameFunctionDeclarationStrictES6.errors.txt | 32 ++++++++++++++++ ...pedSameNameFunctionDeclarationStrictES6.js | 37 ++++++++++++++++++ ...ockScopedSameNameFunctionDeclarationES5.ts | 17 +++++++++ ...ockScopedSameNameFunctionDeclarationES6.ts | 17 +++++++++ ...pedSameNameFunctionDeclarationStrictES5.ts | 18 +++++++++ ...pedSameNameFunctionDeclarationStrictES6.ts | 18 +++++++++ 12 files changed, 358 insertions(+) create mode 100644 tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.errors.txt create mode 100644 tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.js create mode 100644 tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.errors.txt create mode 100644 tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.js create mode 100644 tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt create mode 100644 tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.js create mode 100644 tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.errors.txt create mode 100644 tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.js create mode 100644 tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts create mode 100644 tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts create mode 100644 tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts create mode 100644 tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.errors.txt b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.errors.txt new file mode 100644 index 00000000000..3efa85d1cc7 --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.errors.txt @@ -0,0 +1,37 @@ +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts(3,18): error TS2393: Duplicate function implementation. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts(5,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts(8,18): error TS2393: Duplicate function implementation. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts(10,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts(12,5): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts(16,1): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts (6 errors) ==== + function foo(a: number) { + if (a === 1) { + function foo() { } // duplicate function + ~~~ +!!! error TS2393: Duplicate function implementation. + foo(); + foo(10); // not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + else { + function foo() { } // duplicate function + ~~~ +!!! error TS2393: Duplicate function implementation. + foo(); + foo(10); // not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + foo(10); // not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + foo(); + } + foo(10); + foo(); // not ok - needs number + ~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.js b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.js new file mode 100644 index 00000000000..4c7721f9b43 --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.js @@ -0,0 +1,35 @@ +//// [blockScopedSameNameFunctionDeclarationES5.ts] +function foo(a: number) { + if (a === 1) { + function foo() { } // duplicate function + foo(); + foo(10); // not ok + } + else { + function foo() { } // duplicate function + foo(); + foo(10); // not ok + } + foo(10); // not ok + foo(); +} +foo(10); +foo(); // not ok - needs number + +//// [blockScopedSameNameFunctionDeclarationES5.js] +function foo(a) { + if (a === 1) { + function foo() { } // duplicate function + foo(); + foo(10); // not ok + } + else { + function foo() { } // duplicate function + foo(); + foo(10); // not ok + } + foo(10); // not ok + foo(); +} +foo(10); +foo(); // not ok - needs number diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.errors.txt b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.errors.txt new file mode 100644 index 00000000000..5d15278f098 --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.errors.txt @@ -0,0 +1,37 @@ +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts(3,18): error TS2393: Duplicate function implementation. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts(5,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts(8,18): error TS2393: Duplicate function implementation. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts(10,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts(12,5): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts(16,1): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts (6 errors) ==== + function foo(a: number) { + if (a === 10) { + function foo() { } // duplicate + ~~~ +!!! error TS2393: Duplicate function implementation. + foo(); + foo(10); // not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + else { + function foo() { } // duplicate + ~~~ +!!! error TS2393: Duplicate function implementation. + foo(); + foo(10);// not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + foo(10); // not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + foo(); + } + foo(10); + foo(); // not ok - needs number + ~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.js b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.js new file mode 100644 index 00000000000..c793b74c60a --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.js @@ -0,0 +1,35 @@ +//// [blockScopedSameNameFunctionDeclarationES6.ts] +function foo(a: number) { + if (a === 10) { + function foo() { } // duplicate + foo(); + foo(10); // not ok + } + else { + function foo() { } // duplicate + foo(); + foo(10);// not ok + } + foo(10); // not ok + foo(); +} +foo(10); +foo(); // not ok - needs number + +//// [blockScopedSameNameFunctionDeclarationES6.js] +function foo(a) { + if (a === 10) { + function foo() { } // duplicate + foo(); + foo(10); // not ok + } + else { + function foo() { } // duplicate + foo(); + foo(10); // not ok + } + foo(10); // not ok + foo(); +} +foo(10); +foo(); // not ok - needs number diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt new file mode 100644 index 00000000000..36ce2d8c488 --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt @@ -0,0 +1,38 @@ +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts(4,18): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts(6,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts(9,18): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts(11,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts(14,5): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts(17,1): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts (6 errors) ==== + "use strict"; + function foo(a: number) { + if (a === 1) { + function foo() { } // Error to declare function in block scope + ~~~ +!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. + foo(); + foo(10); // not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + else { + function foo() { } // Error to declare function in block scope + ~~~ +!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. + foo(); + foo(10); // not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + foo(10); + foo(); // not ok - needs number + ~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + foo(10); + foo(); // not ok - needs number + ~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.js b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.js new file mode 100644 index 00000000000..b51be0493cd --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.js @@ -0,0 +1,37 @@ +//// [blockScopedSameNameFunctionDeclarationStrictES5.ts] +"use strict"; +function foo(a: number) { + if (a === 1) { + function foo() { } // Error to declare function in block scope + foo(); + foo(10); // not ok + } + else { + function foo() { } // Error to declare function in block scope + foo(); + foo(10); // not ok + } + foo(10); + foo(); // not ok - needs number +} +foo(10); +foo(); // not ok - needs number + +//// [blockScopedSameNameFunctionDeclarationStrictES5.js] +"use strict"; +function foo(a) { + if (a === 1) { + function foo() { } // Error to declare function in block scope + foo(); + foo(10); // not ok + } + else { + function foo() { } // Error to declare function in block scope + foo(); + foo(10); // not ok + } + foo(10); + foo(); // not ok - needs number +} +foo(10); +foo(); // not ok - needs number diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.errors.txt b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.errors.txt new file mode 100644 index 00000000000..7b8834c5594 --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.errors.txt @@ -0,0 +1,32 @@ +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts(6,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts(11,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts(14,5): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts(17,1): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts (4 errors) ==== + "use strict"; + function foo(a: number) { + if (a === 10) { + function foo() { } + foo(); + foo(10); // not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + else { + function foo() { } + foo(); + foo(10); // not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + foo(10); + foo(); // not ok + ~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + foo(10); + foo(); // not ok - needs number + ~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.js b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.js new file mode 100644 index 00000000000..863df86c031 --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.js @@ -0,0 +1,37 @@ +//// [blockScopedSameNameFunctionDeclarationStrictES6.ts] +"use strict"; +function foo(a: number) { + if (a === 10) { + function foo() { } + foo(); + foo(10); // not ok + } + else { + function foo() { } + foo(); + foo(10); // not ok + } + foo(10); + foo(); // not ok +} +foo(10); +foo(); // not ok - needs number + +//// [blockScopedSameNameFunctionDeclarationStrictES6.js] +"use strict"; +function foo(a) { + if (a === 10) { + function foo() { } + foo(); + foo(10); // not ok + } + else { + function foo() { } + foo(); + foo(10); // not ok + } + foo(10); + foo(); // not ok +} +foo(10); +foo(); // not ok - needs number diff --git a/tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts b/tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts new file mode 100644 index 00000000000..a5e10d19af2 --- /dev/null +++ b/tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts @@ -0,0 +1,17 @@ +// @target: ES5 +function foo(a: number) { + if (a === 1) { + function foo() { } // duplicate function + foo(); + foo(10); // not ok + } + else { + function foo() { } // duplicate function + foo(); + foo(10); // not ok + } + foo(10); // not ok + foo(); +} +foo(10); +foo(); // not ok - needs number \ No newline at end of file diff --git a/tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts b/tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts new file mode 100644 index 00000000000..c97e50964e7 --- /dev/null +++ b/tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts @@ -0,0 +1,17 @@ +// @target: ES6 +function foo(a: number) { + if (a === 10) { + function foo() { } // duplicate + foo(); + foo(10); // not ok + } + else { + function foo() { } // duplicate + foo(); + foo(10);// not ok + } + foo(10); // not ok + foo(); +} +foo(10); +foo(); // not ok - needs number \ No newline at end of file diff --git a/tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts b/tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts new file mode 100644 index 00000000000..a0073c75d43 --- /dev/null +++ b/tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts @@ -0,0 +1,18 @@ +// @target: ES5 +"use strict"; +function foo(a: number) { + if (a === 1) { + function foo() { } // Error to declare function in block scope + foo(); + foo(10); // not ok + } + else { + function foo() { } // Error to declare function in block scope + foo(); + foo(10); // not ok + } + foo(10); + foo(); // not ok - needs number +} +foo(10); +foo(); // not ok - needs number \ No newline at end of file diff --git a/tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts b/tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts new file mode 100644 index 00000000000..34d73a05201 --- /dev/null +++ b/tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts @@ -0,0 +1,18 @@ +// @target: ES6 +"use strict"; +function foo(a: number) { + if (a === 10) { + function foo() { } + foo(); + foo(10); // not ok + } + else { + function foo() { } + foo(); + foo(10); // not ok + } + foo(10); + foo(); // not ok +} +foo(10); +foo(); // not ok - needs number \ No newline at end of file