Add test case for nested object spread / methods

See #16765.
This commit is contained in:
Jan Melcher
2017-06-27 18:03:16 +02:00
committed by Ron Buckton
parent 09e7e88a19
commit d48ac07e14
4 changed files with 89 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
//// [objectSpreadWithinMethodWithinObjectWithSpread.ts]
const obj = {};
const a = {
...obj,
prop() {
return {
...obj,
metadata: 213
};
}
};
//// [objectSpreadWithinMethodWithinObjectWithSpread.js]
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
var obj = {};
var a = __assign({}, obj, { prop: function () {
return __assign({}, obj, { metadata: 213 });
} });

View File

@@ -0,0 +1,24 @@
=== tests/cases/compiler/objectSpreadWithinMethodWithinObjectWithSpread.ts ===
const obj = {};
>obj : Symbol(obj, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 0, 5))
const a = {
>a : Symbol(a, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 1, 5))
...obj,
>obj : Symbol(obj, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 0, 5))
prop() {
>prop : Symbol(prop, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 2, 11))
return {
...obj,
>obj : Symbol(obj, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 0, 5))
metadata: 213
>metadata : Symbol(metadata, Decl(objectSpreadWithinMethodWithinObjectWithSpread.ts, 5, 19))
};
}
};

View File

@@ -0,0 +1,29 @@
=== tests/cases/compiler/objectSpreadWithinMethodWithinObjectWithSpread.ts ===
const obj = {};
>obj : {}
>{} : {}
const a = {
>a : { prop(): { metadata: number; }; }
>{ ...obj, prop() { return { ...obj, metadata: 213 }; }} : { prop(): { metadata: number; }; }
...obj,
>obj : {}
prop() {
>prop : () => { metadata: number; }
return {
>{ ...obj, metadata: 213 } : { metadata: number; }
...obj,
>obj : {}
metadata: 213
>metadata : number
>213 : 213
};
}
};

View File

@@ -0,0 +1,10 @@
const obj = {};
const a = {
...obj,
prop() {
return {
...obj,
metadata: 213
};
}
};