Test cases for functions with same name present in the outerscope

This commit is contained in:
Sheetal Nandi 2016-04-11 14:09:27 -07:00
parent 2dffa5a601
commit 4b0cb640c3
12 changed files with 358 additions and 0 deletions

View file

@ -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.

View file

@ -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

View file

@ -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.

View file

@ -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

View file

@ -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.

View file

@ -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

View file

@ -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.

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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