Add tests for symbol properties
This commit is contained in:
parent
b60fa1467f
commit
779661c8da
11
tests/cases/conformance/es6/Symbols/symbolProperty10.ts
Normal file
11
tests/cases/conformance/es6/Symbols/symbolProperty10.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
//@target: ES6
|
||||
class C {
|
||||
[Symbol.iterator]: { x; y };
|
||||
}
|
||||
interface I {
|
||||
[Symbol.iterator]?: { x };
|
||||
}
|
||||
|
||||
var i: I;
|
||||
i = new C;
|
||||
var c: C = i;
|
9
tests/cases/conformance/es6/Symbols/symbolProperty11.ts
Normal file
9
tests/cases/conformance/es6/Symbols/symbolProperty11.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
//@target: ES6
|
||||
class C { }
|
||||
interface I {
|
||||
[Symbol.iterator]?: { x };
|
||||
}
|
||||
|
||||
var i: I;
|
||||
i = new C;
|
||||
var c: C = i;
|
11
tests/cases/conformance/es6/Symbols/symbolProperty12.ts
Normal file
11
tests/cases/conformance/es6/Symbols/symbolProperty12.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
//@target: ES6
|
||||
class C {
|
||||
private [Symbol.iterator]: { x };
|
||||
}
|
||||
interface I {
|
||||
[Symbol.iterator]: { x };
|
||||
}
|
||||
|
||||
var i: I;
|
||||
i = new C;
|
||||
var c: C = i;
|
17
tests/cases/conformance/es6/Symbols/symbolProperty13.ts
Normal file
17
tests/cases/conformance/es6/Symbols/symbolProperty13.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
//@target: ES6
|
||||
class C {
|
||||
[Symbol.iterator]: { x; y };
|
||||
}
|
||||
interface I {
|
||||
[Symbol.iterator]: { x };
|
||||
}
|
||||
|
||||
declare function foo(i: I): I;
|
||||
declare function foo(a: any): any;
|
||||
|
||||
declare function bar(i: C): C;
|
||||
declare function bar(a: any): any;
|
||||
|
||||
foo(new C);
|
||||
var i: I;
|
||||
bar(i);
|
17
tests/cases/conformance/es6/Symbols/symbolProperty14.ts
Normal file
17
tests/cases/conformance/es6/Symbols/symbolProperty14.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
//@target: ES6
|
||||
class C {
|
||||
[Symbol.iterator]: { x; y };
|
||||
}
|
||||
interface I {
|
||||
[Symbol.iterator]?: { x };
|
||||
}
|
||||
|
||||
declare function foo(i: I): I;
|
||||
declare function foo(a: any): any;
|
||||
|
||||
declare function bar(i: C): C;
|
||||
declare function bar(a: any): any;
|
||||
|
||||
foo(new C);
|
||||
var i: I;
|
||||
bar(i);
|
15
tests/cases/conformance/es6/Symbols/symbolProperty15.ts
Normal file
15
tests/cases/conformance/es6/Symbols/symbolProperty15.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
//@target: ES6
|
||||
class C { }
|
||||
interface I {
|
||||
[Symbol.iterator]?: { x };
|
||||
}
|
||||
|
||||
declare function foo(i: I): I;
|
||||
declare function foo(a: any): any;
|
||||
|
||||
declare function bar(i: C): C;
|
||||
declare function bar(a: any): any;
|
||||
|
||||
foo(new C);
|
||||
var i: I;
|
||||
bar(i);
|
17
tests/cases/conformance/es6/Symbols/symbolProperty16.ts
Normal file
17
tests/cases/conformance/es6/Symbols/symbolProperty16.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
//@target: ES6
|
||||
class C {
|
||||
private [Symbol.iterator]: { x };
|
||||
}
|
||||
interface I {
|
||||
[Symbol.iterator]: { x };
|
||||
}
|
||||
|
||||
declare function foo(i: I): I;
|
||||
declare function foo(a: any): any;
|
||||
|
||||
declare function bar(i: C): C;
|
||||
declare function bar(a: any): any;
|
||||
|
||||
foo(new C);
|
||||
var i: I;
|
||||
bar(i);
|
9
tests/cases/conformance/es6/Symbols/symbolProperty17.ts
Normal file
9
tests/cases/conformance/es6/Symbols/symbolProperty17.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
//@target: ES6
|
||||
interface I {
|
||||
[Symbol.iterator]: number;
|
||||
[s: Symbol]: string;
|
||||
"__@iterator": string;
|
||||
}
|
||||
|
||||
var i: I;
|
||||
var it = i[Symbol.iterator];
|
10
tests/cases/conformance/es6/Symbols/symbolProperty18.ts
Normal file
10
tests/cases/conformance/es6/Symbols/symbolProperty18.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
//@target: ES6
|
||||
var i = {
|
||||
[Symbol.iterator]: 0,
|
||||
[Symbol.toStringTag]() { return "" },
|
||||
set [Symbol.toPrimitive](p: boolean) { }
|
||||
}
|
||||
|
||||
var it = i[Symbol.iterator];
|
||||
var str = i[Symbol.toStringTag]();
|
||||
i[Symbol.toPrimitive] = false;
|
8
tests/cases/conformance/es6/Symbols/symbolProperty19.ts
Normal file
8
tests/cases/conformance/es6/Symbols/symbolProperty19.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
//@target: ES6
|
||||
var i = {
|
||||
[Symbol.iterator]: { p: null },
|
||||
[Symbol.toStringTag]() { return { p: undefined }; }
|
||||
}
|
||||
|
||||
var it = i[Symbol.iterator];
|
||||
var str = i[Symbol.toStringTag]();
|
10
tests/cases/conformance/es6/Symbols/symbolProperty20.ts
Normal file
10
tests/cases/conformance/es6/Symbols/symbolProperty20.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
//@target: ES6
|
||||
interface I {
|
||||
[Symbol.iterator]: (s: string) => string;
|
||||
[Symbol.toStringTag](s: number): number;
|
||||
}
|
||||
|
||||
var i: I = {
|
||||
[Symbol.iterator]: s => s,
|
||||
[Symbol.toStringTag](n) { return n; }
|
||||
}
|
13
tests/cases/conformance/es6/Symbols/symbolProperty21.ts
Normal file
13
tests/cases/conformance/es6/Symbols/symbolProperty21.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
//@target: ES6
|
||||
interface I<T, U> {
|
||||
[Symbol.unscopables]: T;
|
||||
[Symbol.isConcatSpreadable]: U;
|
||||
}
|
||||
|
||||
declare function foo<T, U>(p: I<T, U>): { t: T; u: U };
|
||||
|
||||
foo({
|
||||
[Symbol.isConcatSpreadable]: "",
|
||||
[Symbol.isRegExp]: 0,
|
||||
[Symbol.unscopables]: true
|
||||
});
|
8
tests/cases/conformance/es6/Symbols/symbolProperty22.ts
Normal file
8
tests/cases/conformance/es6/Symbols/symbolProperty22.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
//@target: ES6
|
||||
interface I<T, U> {
|
||||
[Symbol.unscopables](x: T): U;
|
||||
}
|
||||
|
||||
declare function foo<T, U>(p1: T, p2: I<T, U>): U;
|
||||
|
||||
foo("", { [Symbol.unscopables]: s => s.length });
|
10
tests/cases/conformance/es6/Symbols/symbolProperty23.ts
Normal file
10
tests/cases/conformance/es6/Symbols/symbolProperty23.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
//@target: ES6
|
||||
interface I {
|
||||
[Symbol.toPrimitive]: () => boolean;
|
||||
}
|
||||
|
||||
class C implements I {
|
||||
[Symbol.toPrimitive]() {
|
||||
return true;
|
||||
}
|
||||
}
|
10
tests/cases/conformance/es6/Symbols/symbolProperty24.ts
Normal file
10
tests/cases/conformance/es6/Symbols/symbolProperty24.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
//@target: ES6
|
||||
interface I {
|
||||
[Symbol.toPrimitive]: () => boolean;
|
||||
}
|
||||
|
||||
class C implements I {
|
||||
[Symbol.toPrimitive]() {
|
||||
return "";
|
||||
}
|
||||
}
|
10
tests/cases/conformance/es6/Symbols/symbolProperty25.ts
Normal file
10
tests/cases/conformance/es6/Symbols/symbolProperty25.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
//@target: ES6
|
||||
interface I {
|
||||
[Symbol.toPrimitive]: () => boolean;
|
||||
}
|
||||
|
||||
class C implements I {
|
||||
[Symbol.toStringTag]() {
|
||||
return "";
|
||||
}
|
||||
}
|
12
tests/cases/conformance/es6/Symbols/symbolProperty26.ts
Normal file
12
tests/cases/conformance/es6/Symbols/symbolProperty26.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
//@target: ES6
|
||||
class C1 {
|
||||
[Symbol.toStringTag]() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
class C2 extends C1 {
|
||||
[Symbol.toStringTag]() {
|
||||
return "";
|
||||
}
|
||||
}
|
12
tests/cases/conformance/es6/Symbols/symbolProperty27.ts
Normal file
12
tests/cases/conformance/es6/Symbols/symbolProperty27.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
//@target: ES6
|
||||
class C1 {
|
||||
[Symbol.toStringTag]() {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
class C2 extends C1 {
|
||||
[Symbol.toStringTag]() {
|
||||
return "";
|
||||
}
|
||||
}
|
11
tests/cases/conformance/es6/Symbols/symbolProperty28.ts
Normal file
11
tests/cases/conformance/es6/Symbols/symbolProperty28.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
//@target: ES6
|
||||
class C1 {
|
||||
[Symbol.toStringTag]() {
|
||||
return { x: "" };
|
||||
}
|
||||
}
|
||||
|
||||
class C2 extends C1 { }
|
||||
|
||||
var c: C2;
|
||||
var obj = c[Symbol.toStringTag]().x;
|
7
tests/cases/conformance/es6/Symbols/symbolProperty29.ts
Normal file
7
tests/cases/conformance/es6/Symbols/symbolProperty29.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
//@target: ES6
|
||||
class C1 {
|
||||
[Symbol.toStringTag]() {
|
||||
return { x: "" };
|
||||
}
|
||||
[s: Symbol]: () => { x: string };
|
||||
}
|
7
tests/cases/conformance/es6/Symbols/symbolProperty30.ts
Normal file
7
tests/cases/conformance/es6/Symbols/symbolProperty30.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
//@target: ES6
|
||||
class C1 {
|
||||
[Symbol.toStringTag]() {
|
||||
return { x: "" };
|
||||
}
|
||||
[s: Symbol]: () => { x: number };
|
||||
}
|
9
tests/cases/conformance/es6/Symbols/symbolProperty31.ts
Normal file
9
tests/cases/conformance/es6/Symbols/symbolProperty31.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
//@target: ES6
|
||||
class C1 {
|
||||
[Symbol.toStringTag]() {
|
||||
return { x: "" };
|
||||
}
|
||||
}
|
||||
class C2 extends C1 {
|
||||
[s: Symbol]: () => { x: string };
|
||||
}
|
9
tests/cases/conformance/es6/Symbols/symbolProperty32.ts
Normal file
9
tests/cases/conformance/es6/Symbols/symbolProperty32.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
//@target: ES6
|
||||
class C1 {
|
||||
[Symbol.toStringTag]() {
|
||||
return { x: "" };
|
||||
}
|
||||
}
|
||||
class C2 extends C1 {
|
||||
[s: Symbol]: () => { x: number };
|
||||
}
|
9
tests/cases/conformance/es6/Symbols/symbolProperty33.ts
Normal file
9
tests/cases/conformance/es6/Symbols/symbolProperty33.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
//@target: ES6
|
||||
class C1 extends C2 {
|
||||
[Symbol.toStringTag]() {
|
||||
return { x: "" };
|
||||
}
|
||||
}
|
||||
class C2 {
|
||||
[s: Symbol]: () => { x: string };
|
||||
}
|
9
tests/cases/conformance/es6/Symbols/symbolProperty34.ts
Normal file
9
tests/cases/conformance/es6/Symbols/symbolProperty34.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
//@target: ES6
|
||||
class C1 extends C2 {
|
||||
[Symbol.toStringTag]() {
|
||||
return { x: "" };
|
||||
}
|
||||
}
|
||||
class C2 {
|
||||
[s: Symbol]: () => { x: number };
|
||||
}
|
9
tests/cases/conformance/es6/Symbols/symbolProperty35.ts
Normal file
9
tests/cases/conformance/es6/Symbols/symbolProperty35.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
//@target: ES6
|
||||
interface I1 {
|
||||
[Symbol.toStringTag](): { x: string }
|
||||
}
|
||||
interface I2 {
|
||||
[Symbol.toStringTag](): { x: number }
|
||||
}
|
||||
|
||||
interface I3 extends I1, I2 { }
|
5
tests/cases/conformance/es6/Symbols/symbolProperty36.ts
Normal file
5
tests/cases/conformance/es6/Symbols/symbolProperty36.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
//@target: ES6
|
||||
var x = {
|
||||
[Symbol.isConcatSpreadable]: 0,
|
||||
[Symbol.isConcatSpreadable]: 1
|
||||
}
|
5
tests/cases/conformance/es6/Symbols/symbolProperty37.ts
Normal file
5
tests/cases/conformance/es6/Symbols/symbolProperty37.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
//@target: ES6
|
||||
interface I {
|
||||
[Symbol.isConcatSpreadable]: string;
|
||||
[Symbol.isConcatSpreadable]: string;
|
||||
}
|
7
tests/cases/conformance/es6/Symbols/symbolProperty38.ts
Normal file
7
tests/cases/conformance/es6/Symbols/symbolProperty38.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
//@target: ES6
|
||||
interface I {
|
||||
[Symbol.isConcatSpreadable]: string;
|
||||
}
|
||||
interface I {
|
||||
[Symbol.isConcatSpreadable]: string;
|
||||
}
|
11
tests/cases/conformance/es6/Symbols/symbolProperty39.ts
Normal file
11
tests/cases/conformance/es6/Symbols/symbolProperty39.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
//@target: ES6
|
||||
class C {
|
||||
[Symbol.iterator](x: string): string;
|
||||
[Symbol.iterator](x: number): number;
|
||||
[Symbol.iterator](x: any) {
|
||||
return undefined;
|
||||
}
|
||||
[Symbol.iterator](x: any) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
12
tests/cases/conformance/es6/Symbols/symbolProperty40.ts
Normal file
12
tests/cases/conformance/es6/Symbols/symbolProperty40.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
//@target: ES6
|
||||
class C {
|
||||
[Symbol.iterator](x: string): string;
|
||||
[Symbol.iterator](x: number): number;
|
||||
[Symbol.iterator](x: any) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
var c = new C;
|
||||
c[Symbol.iterator]("");
|
||||
c[Symbol.iterator](0);
|
12
tests/cases/conformance/es6/Symbols/symbolProperty41.ts
Normal file
12
tests/cases/conformance/es6/Symbols/symbolProperty41.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
//@target: ES6
|
||||
class C {
|
||||
[Symbol.iterator](x: string): { x: string };
|
||||
[Symbol.iterator](x: "hello"): { x: string; hello: string };
|
||||
[Symbol.iterator](x: any) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
var c = new C;
|
||||
c[Symbol.iterator]("");
|
||||
c[Symbol.iterator]("hello");
|
8
tests/cases/conformance/es6/Symbols/symbolProperty42.ts
Normal file
8
tests/cases/conformance/es6/Symbols/symbolProperty42.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
//@target: ES6
|
||||
class C {
|
||||
[Symbol.iterator](x: string): string;
|
||||
static [Symbol.iterator](x: number): number;
|
||||
[Symbol.iterator](x: any) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
5
tests/cases/conformance/es6/Symbols/symbolProperty43.ts
Normal file
5
tests/cases/conformance/es6/Symbols/symbolProperty43.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
//@target: ES6
|
||||
class C {
|
||||
[Symbol.iterator](x: string): string;
|
||||
[Symbol.iterator](x: number): number;
|
||||
}
|
9
tests/cases/conformance/es6/Symbols/symbolProperty44.ts
Normal file
9
tests/cases/conformance/es6/Symbols/symbolProperty44.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
//@target: ES6
|
||||
class C {
|
||||
get [Symbol.hasInstance]() {
|
||||
return "";
|
||||
}
|
||||
get [Symbol.hasInstance]() {
|
||||
return "";
|
||||
}
|
||||
}
|
9
tests/cases/conformance/es6/Symbols/symbolProperty45.ts
Normal file
9
tests/cases/conformance/es6/Symbols/symbolProperty45.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
//@target: ES6
|
||||
class C {
|
||||
get [Symbol.hasInstance]() {
|
||||
return "";
|
||||
}
|
||||
get [Symbol.toPrimitive]() {
|
||||
return "";
|
||||
}
|
||||
}
|
12
tests/cases/conformance/es6/Symbols/symbolProperty46.ts
Normal file
12
tests/cases/conformance/es6/Symbols/symbolProperty46.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
//@target: ES6
|
||||
class C {
|
||||
get [Symbol.hasInstance]() {
|
||||
return "";
|
||||
}
|
||||
// Should take a string
|
||||
set [Symbol.hasInstance](x) {
|
||||
}
|
||||
}
|
||||
|
||||
(new C)[Symbol.hasInstance] = 0;
|
||||
(new C)[Symbol.hasInstance] = "";
|
12
tests/cases/conformance/es6/Symbols/symbolProperty47.ts
Normal file
12
tests/cases/conformance/es6/Symbols/symbolProperty47.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
//@target: ES6
|
||||
class C {
|
||||
get [Symbol.hasInstance]() {
|
||||
return "";
|
||||
}
|
||||
// Should take a string
|
||||
set [Symbol.hasInstance](x: number) {
|
||||
}
|
||||
}
|
||||
|
||||
(new C)[Symbol.hasInstance] = 0;
|
||||
(new C)[Symbol.hasInstance] = "";
|
8
tests/cases/conformance/es6/Symbols/symbolProperty48.ts
Normal file
8
tests/cases/conformance/es6/Symbols/symbolProperty48.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
//@target: ES6
|
||||
module M {
|
||||
var Symbol;
|
||||
|
||||
class C {
|
||||
[Symbol.iterator]() { }
|
||||
}
|
||||
}
|
8
tests/cases/conformance/es6/Symbols/symbolProperty49.ts
Normal file
8
tests/cases/conformance/es6/Symbols/symbolProperty49.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
//@target: ES6
|
||||
module M {
|
||||
export var Symbol;
|
||||
|
||||
class C {
|
||||
[Symbol.iterator]() { }
|
||||
}
|
||||
}
|
8
tests/cases/conformance/es6/Symbols/symbolProperty50.ts
Normal file
8
tests/cases/conformance/es6/Symbols/symbolProperty50.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
//@target: ES6
|
||||
module M {
|
||||
interface Symbol { }
|
||||
|
||||
class C {
|
||||
[Symbol.iterator]() { }
|
||||
}
|
||||
}
|
8
tests/cases/conformance/es6/Symbols/symbolProperty51.ts
Normal file
8
tests/cases/conformance/es6/Symbols/symbolProperty51.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
//@target: ES6
|
||||
module M {
|
||||
module Symbol { }
|
||||
|
||||
class C {
|
||||
[Symbol.iterator]() { }
|
||||
}
|
||||
}
|
6
tests/cases/conformance/es6/Symbols/symbolProperty52.ts
Normal file
6
tests/cases/conformance/es6/Symbols/symbolProperty52.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
//@target: ES6
|
||||
var obj = {
|
||||
[Symbol.nonsense]: 0
|
||||
};
|
||||
|
||||
obj = {};
|
4
tests/cases/conformance/es6/Symbols/symbolProperty53.ts
Normal file
4
tests/cases/conformance/es6/Symbols/symbolProperty53.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
//@target: ES6
|
||||
var obj = {
|
||||
[Symbol.for]: 0
|
||||
};
|
4
tests/cases/conformance/es6/Symbols/symbolProperty54.ts
Normal file
4
tests/cases/conformance/es6/Symbols/symbolProperty54.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
//@target: ES6
|
||||
var obj = {
|
||||
[Symbol.prototype]: 0
|
||||
};
|
11
tests/cases/conformance/es6/Symbols/symbolProperty9.ts
Normal file
11
tests/cases/conformance/es6/Symbols/symbolProperty9.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
//@target: ES6
|
||||
class C {
|
||||
[Symbol.iterator]: { x; y };
|
||||
}
|
||||
interface I {
|
||||
[Symbol.iterator]: { x };
|
||||
}
|
||||
|
||||
var i: I;
|
||||
i = new C;
|
||||
var c: C = i;
|
Loading…
Reference in a new issue