mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add tests
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
//// [superSymbolIndexedAccess1.ts]
|
||||
var symbol = Symbol.for('myThing');
|
||||
|
||||
class Foo {
|
||||
[symbol]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
[symbol]() {
|
||||
return super[symbol]();
|
||||
}
|
||||
}
|
||||
|
||||
//// [superSymbolIndexedAccess1.js]
|
||||
var symbol = Symbol.for('myThing');
|
||||
class Foo {
|
||||
[symbol]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
class Bar extends Foo {
|
||||
[symbol]() {
|
||||
return super[symbol]();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
=== tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess1.ts ===
|
||||
var symbol = Symbol.for('myThing');
|
||||
>symbol : Symbol(symbol, Decl(superSymbolIndexedAccess1.ts, 0, 3))
|
||||
>Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11))
|
||||
>for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42))
|
||||
|
||||
class Foo {
|
||||
>Foo : Symbol(Foo, Decl(superSymbolIndexedAccess1.ts, 0, 35))
|
||||
|
||||
[symbol]() {
|
||||
>symbol : Symbol(symbol, Decl(superSymbolIndexedAccess1.ts, 0, 3))
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
>Bar : Symbol(Bar, Decl(superSymbolIndexedAccess1.ts, 6, 1))
|
||||
>Foo : Symbol(Foo, Decl(superSymbolIndexedAccess1.ts, 0, 35))
|
||||
|
||||
[symbol]() {
|
||||
>symbol : Symbol(symbol, Decl(superSymbolIndexedAccess1.ts, 0, 3))
|
||||
|
||||
return super[symbol]();
|
||||
>super : Symbol(Foo, Decl(superSymbolIndexedAccess1.ts, 0, 35))
|
||||
>symbol : Symbol(symbol, Decl(superSymbolIndexedAccess1.ts, 0, 3))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
=== tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess1.ts ===
|
||||
var symbol = Symbol.for('myThing');
|
||||
>symbol : symbol
|
||||
>Symbol.for('myThing') : symbol
|
||||
>Symbol.for : (key: string) => symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>for : (key: string) => symbol
|
||||
>'myThing' : string
|
||||
|
||||
class Foo {
|
||||
>Foo : Foo
|
||||
|
||||
[symbol]() {
|
||||
>symbol : symbol
|
||||
|
||||
return 0;
|
||||
>0 : number
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
>Bar : Bar
|
||||
>Foo : Foo
|
||||
|
||||
[symbol]() {
|
||||
>symbol : symbol
|
||||
|
||||
return super[symbol]();
|
||||
>super[symbol]() : any
|
||||
>super[symbol] : any
|
||||
>super : Foo
|
||||
>symbol : symbol
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//// [superSymbolIndexedAccess2.ts]
|
||||
|
||||
class Foo {
|
||||
[Symbol.isConcatSpreadable]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
[Symbol.isConcatSpreadable]() {
|
||||
return super[Symbol.isConcatSpreadable]();
|
||||
}
|
||||
}
|
||||
|
||||
//// [superSymbolIndexedAccess2.js]
|
||||
class Foo {
|
||||
[Symbol.isConcatSpreadable]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
class Bar extends Foo {
|
||||
[Symbol.isConcatSpreadable]() {
|
||||
return super[Symbol.isConcatSpreadable]();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
=== tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess2.ts ===
|
||||
|
||||
class Foo {
|
||||
>Foo : Symbol(Foo, Decl(superSymbolIndexedAccess2.ts, 0, 0))
|
||||
|
||||
[Symbol.isConcatSpreadable]() {
|
||||
>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11))
|
||||
>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24))
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
>Bar : Symbol(Bar, Decl(superSymbolIndexedAccess2.ts, 5, 1))
|
||||
>Foo : Symbol(Foo, Decl(superSymbolIndexedAccess2.ts, 0, 0))
|
||||
|
||||
[Symbol.isConcatSpreadable]() {
|
||||
>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11))
|
||||
>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24))
|
||||
|
||||
return super[Symbol.isConcatSpreadable]();
|
||||
>super : Symbol(Foo, Decl(superSymbolIndexedAccess2.ts, 0, 0))
|
||||
>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11))
|
||||
>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
=== tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess2.ts ===
|
||||
|
||||
class Foo {
|
||||
>Foo : Foo
|
||||
|
||||
[Symbol.isConcatSpreadable]() {
|
||||
>Symbol.isConcatSpreadable : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isConcatSpreadable : symbol
|
||||
|
||||
return 0;
|
||||
>0 : number
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
>Bar : Bar
|
||||
>Foo : Foo
|
||||
|
||||
[Symbol.isConcatSpreadable]() {
|
||||
>Symbol.isConcatSpreadable : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isConcatSpreadable : symbol
|
||||
|
||||
return super[Symbol.isConcatSpreadable]();
|
||||
>super[Symbol.isConcatSpreadable]() : number
|
||||
>super[Symbol.isConcatSpreadable] : () => number
|
||||
>super : Foo
|
||||
>Symbol.isConcatSpreadable : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>isConcatSpreadable : symbol
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess3.ts(11,16): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess3.ts (1 errors) ====
|
||||
var symbol = Symbol.for('myThing');
|
||||
|
||||
class Foo {
|
||||
[symbol]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
[symbol]() {
|
||||
return super[Bar]();
|
||||
~~~~~~~~~~
|
||||
!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
//// [superSymbolIndexedAccess3.ts]
|
||||
var symbol = Symbol.for('myThing');
|
||||
|
||||
class Foo {
|
||||
[symbol]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
[symbol]() {
|
||||
return super[Bar]();
|
||||
}
|
||||
}
|
||||
|
||||
//// [superSymbolIndexedAccess3.js]
|
||||
var symbol = Symbol.for('myThing');
|
||||
class Foo {
|
||||
[symbol]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
class Bar extends Foo {
|
||||
[symbol]() {
|
||||
return super[Bar]();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess4.ts(5,16): error TS2335: 'super' can only be referenced in a derived class.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess4.ts (1 errors) ====
|
||||
var symbol = Symbol.for('myThing');
|
||||
|
||||
class Bar {
|
||||
[symbol]() {
|
||||
return super[symbol]();
|
||||
~~~~~
|
||||
!!! error TS2335: 'super' can only be referenced in a derived class.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [superSymbolIndexedAccess4.ts]
|
||||
var symbol = Symbol.for('myThing');
|
||||
|
||||
class Bar {
|
||||
[symbol]() {
|
||||
return super[symbol]();
|
||||
}
|
||||
}
|
||||
|
||||
//// [superSymbolIndexedAccess4.js]
|
||||
var symbol = Symbol.for('myThing');
|
||||
class Bar {
|
||||
[symbol]() {
|
||||
return super[symbol]();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//@target: ES6
|
||||
var symbol = Symbol.for('myThing');
|
||||
|
||||
class Foo {
|
||||
[symbol]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
[symbol]() {
|
||||
return super[symbol]();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
//@target: ES6
|
||||
|
||||
class Foo {
|
||||
[Symbol.isConcatSpreadable]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
[Symbol.isConcatSpreadable]() {
|
||||
return super[Symbol.isConcatSpreadable]();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//@target: ES6
|
||||
var symbol = Symbol.for('myThing');
|
||||
|
||||
class Foo {
|
||||
[symbol]() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
[symbol]() {
|
||||
return super[Bar]();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
//@target: ES6
|
||||
var symbol = Symbol.for('myThing');
|
||||
|
||||
class Bar {
|
||||
[symbol]() {
|
||||
return super[symbol]();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user