Emit tests for computed properties
This commit is contained in:
parent
17a09d1d36
commit
0e864143de
16 changed files with 238 additions and 0 deletions
14
tests/baselines/reference/computedPropertyNames1.js
Normal file
14
tests/baselines/reference/computedPropertyNames1.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
//// [computedPropertyNames1.ts]
|
||||
var v = {
|
||||
get [0 + 1]() { return 0 },
|
||||
set [0 + 1](v) { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames1.js]
|
||||
var v = {
|
||||
get [0 + 1]() {
|
||||
return 0;
|
||||
},
|
||||
set [0 + 1](v) {
|
||||
}
|
||||
};
|
19
tests/baselines/reference/computedPropertyNames2.errors.txt
Normal file
19
tests/baselines/reference/computedPropertyNames2.errors.txt
Normal file
|
@ -0,0 +1,19 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(6,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(8,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts (2 errors) ====
|
||||
var methodName = "method";
|
||||
var accessorName = "accessor";
|
||||
class C {
|
||||
[methodName]() { }
|
||||
static [methodName]() { }
|
||||
get [accessorName]() { }
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
set [accessorName](v) { }
|
||||
static get [accessorName]() { }
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
static set [accessorName](v) { }
|
||||
}
|
48
tests/baselines/reference/computedPropertyNames2.js
Normal file
48
tests/baselines/reference/computedPropertyNames2.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
//// [computedPropertyNames2.ts]
|
||||
var methodName = "method";
|
||||
var accessorName = "accessor";
|
||||
class C {
|
||||
[methodName]() { }
|
||||
static [methodName]() { }
|
||||
get [accessorName]() { }
|
||||
set [accessorName](v) { }
|
||||
static get [accessorName]() { }
|
||||
static set [accessorName](v) { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames2.js]
|
||||
var methodName = "method";
|
||||
var accessorName = "accessor";
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[methodName] = function () {
|
||||
};
|
||||
C[methodName] = function () {
|
||||
};
|
||||
Object.defineProperty(C.prototype, accessorName, {
|
||||
get: function () {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, accessorName, {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, accessorName, {
|
||||
get: function () {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, accessorName, {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
18
tests/baselines/reference/computedPropertyNames3.errors.txt
Normal file
18
tests/baselines/reference/computedPropertyNames3.errors.txt
Normal file
|
@ -0,0 +1,18 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(5,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(7,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts (2 errors) ====
|
||||
var id;
|
||||
class C {
|
||||
[0 + 1]() { }
|
||||
static [() => { }]() { }
|
||||
get [delete id]() { }
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
set [[0, 1]](v) { }
|
||||
static get [<String>""]() { }
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
static set [id.toString()](v) { }
|
||||
}
|
47
tests/baselines/reference/computedPropertyNames3.js
Normal file
47
tests/baselines/reference/computedPropertyNames3.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
//// [computedPropertyNames3.ts]
|
||||
var id;
|
||||
class C {
|
||||
[0 + 1]() { }
|
||||
static [() => { }]() { }
|
||||
get [delete id]() { }
|
||||
set [[0, 1]](v) { }
|
||||
static get [<String>""]() { }
|
||||
static set [id.toString()](v) { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames3.js]
|
||||
var id;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[0 + 1] = function () {
|
||||
};
|
||||
C[function () {
|
||||
}] = function () {
|
||||
};
|
||||
Object.defineProperty(C.prototype, delete id, {
|
||||
get: function () {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, [0, 1], {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, "", {
|
||||
get: function () {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, id.toString(), {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
13
tests/baselines/reference/parserComputedPropertyName12.js
Normal file
13
tests/baselines/reference/parserComputedPropertyName12.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
//// [parserComputedPropertyName12.ts]
|
||||
class C {
|
||||
[e]() { }
|
||||
}
|
||||
|
||||
//// [parserComputedPropertyName12.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[e] = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
|
@ -0,0 +1,6 @@
|
|||
//// [parserComputedPropertyName17.ts]
|
||||
var v = { set [e](v) { } }
|
||||
|
||||
//// [parserComputedPropertyName17.js]
|
||||
var v = { set [e](v) {
|
||||
} };
|
5
tests/baselines/reference/parserComputedPropertyName2.js
Normal file
5
tests/baselines/reference/parserComputedPropertyName2.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
//// [parserComputedPropertyName2.ts]
|
||||
var v = { [e]: 1 };
|
||||
|
||||
//// [parserComputedPropertyName2.js]
|
||||
var v = { [e]: 1 };
|
17
tests/baselines/reference/parserComputedPropertyName24.js
Normal file
17
tests/baselines/reference/parserComputedPropertyName24.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
//// [parserComputedPropertyName24.ts]
|
||||
class C {
|
||||
set [e](v) { }
|
||||
}
|
||||
|
||||
//// [parserComputedPropertyName24.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
Object.defineProperty(C.prototype, e, {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
6
tests/baselines/reference/parserComputedPropertyName3.js
Normal file
6
tests/baselines/reference/parserComputedPropertyName3.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
//// [parserComputedPropertyName3.ts]
|
||||
var v = { [e]() { } };
|
||||
|
||||
//// [parserComputedPropertyName3.js]
|
||||
var v = { [e]: function () {
|
||||
} };
|
6
tests/baselines/reference/parserComputedPropertyName4.js
Normal file
6
tests/baselines/reference/parserComputedPropertyName4.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
//// [parserComputedPropertyName4.ts]
|
||||
var v = { get [e]() { } };
|
||||
|
||||
//// [parserComputedPropertyName4.js]
|
||||
var v = { get [e]() {
|
||||
} };
|
5
tests/baselines/reference/parserComputedPropertyName6.js
Normal file
5
tests/baselines/reference/parserComputedPropertyName6.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
//// [parserComputedPropertyName6.ts]
|
||||
var v = { [e]: 1, [e + e]: 2 };
|
||||
|
||||
//// [parserComputedPropertyName6.js]
|
||||
var v = { [e]: 1, [e + e]: 2 };
|
|
@ -0,0 +1,5 @@
|
|||
// @target: es6
|
||||
var v = {
|
||||
get [0 + 1]() { return 0 },
|
||||
set [0 + 1](v) { }
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
// @target: es6
|
||||
var methodName = "method";
|
||||
var accessorName = "accessor";
|
||||
class C {
|
||||
[methodName]() { }
|
||||
static [methodName]() { }
|
||||
get [accessorName]() { }
|
||||
set [accessorName](v) { }
|
||||
static get [accessorName]() { }
|
||||
static set [accessorName](v) { }
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
// @target: es6
|
||||
var id;
|
||||
class C {
|
||||
[0 + 1]() { }
|
||||
static [() => { }]() { }
|
||||
get [delete id]() { }
|
||||
set [[0, 1]](v) { }
|
||||
static get [<String>""]() { }
|
||||
static set [id.toString()](v) { }
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
// @target: es6
|
||||
var methodName = "method";
|
||||
var accessorName = "accessor";
|
||||
class C {
|
||||
[methodName](v: string);
|
||||
[methodName]();
|
||||
[methodName](v?: string) { }
|
||||
}
|
Loading…
Reference in a new issue