Skip to content
Snippets Groups Projects
Commit 4c49047f authored by Rick Waldron's avatar Rick Waldron
Browse files

Import tests from Google V8 (Object Literal Concise Method and Property Initialization)

These tests are derived from the following files within the Google V8 project:

        test/mjsunit/harmony/method-name-eval-arguments.js
        test/mjsunit/harmony/object-literals-method.js
        test/mjsunit/harmony/object-literals-property-shorthand.js
        test/mjsunit/harmony/object-literals-super.js
parent 2eca2c71
No related branches found
No related tags found
No related merge requests found
Showing
with 206 additions and 0 deletions
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 12.2.5
description: >
super method calls in object literal concise generator
---*/
var proto = {
method() {
return 42;
}
};
var object = {
*g() {
yield super.method();
}
};
Object.setPrototypeOf(object, proto);
assert.sameValue(
object.g().next().value,
42,
"The value of `object.g().next().value` is `42`, after executing `Object.setPrototypeOf(object, proto);`, where `object " + String(object) + "`"
);
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 12.2.5
desciption: >
object literal property shorthand desciptor defaults
---*/
var x = 1;
var object = {x};
var desc = Object.getOwnPropertyDescriptor(object, 'x');
assert.sameValue(desc.value, 1, "The value of `desc.value` is `1`, where `var desc = Object.getOwnPropertyDescriptor(object, 'x');`");
assert.sameValue(desc.enumerable, true, "The value of `desc.enumerable` is `true`, where `var desc = Object.getOwnPropertyDescriptor(object, 'x');`");
assert.sameValue(desc.writable, true, "The value of `desc.writable` is `true`, where `var desc = Object.getOwnPropertyDescriptor(object, 'x');`");
assert.sameValue(desc.configurable, true, "The value of `desc.configurable` is `true`, where `var desc = Object.getOwnPropertyDescriptor(object, 'x');`");
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 12.2.5
description: >
super method calls in object literal getter
---*/
var proto = {
_x: 42,
get x() {
return 'proto' + this._x;
}
};
var object = {
get x() {
return super.x;
}
};
Object.setPrototypeOf(object, proto);
assert.sameValue(object.x, 'proto42', "The value of `object.x` is `'proto42'`, after executing `Object.setPrototypeOf(object, proto);`");
assert.sameValue(object._x, 42, "The value of `object._x` is `42`, after executing `Object.setPrototypeOf(object, proto);`");
assert.sameValue(
Object.getPrototypeOf(object)._x,
42,
"The value of `Object.getPrototypeOf(object)._x` is `42`"
);
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 12.2.5
description: >
Basic identifier reference property initialization
---*/
var p = "1";
var o = {p};
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 12.2.5
description: >
In non-strict mode, let is a valid Identifier.
flags: [noStrict]
---*/
var let = 1;
var object = {let};
assert.sameValue(object.let, 1, "The value of `object.let` is `1`");
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 12.2.5
description: >
In non-strict mode, let is a valid Identifier.
flags: [noStrict]
---*/
var let = 1;
var object = {let};
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 12.2.5
description: >
super method calls in object literal method
---*/
var proto = {
method(x) {
return 'proto' + x;
}
};
var object = {
method(x) {
return super.method(x);
}
};
Object.setPrototypeOf(object, proto);
assert.sameValue(object.method(42), 'proto42', "`object.method(42)` returns `'proto42'`, after executing `Object.setPrototypeOf(object, proto);`");
assert.sameValue(proto.method(42), 'proto42', "`proto.method(42)` returns `'proto42'`, after executing `Object.setPrototypeOf(object, proto);`");
assert.sameValue(
Object.getPrototypeOf(object).method(42),
'proto42',
"`Object.getPrototypeOf(object).method(42)` returns `'proto42'`"
);
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 12.2.5
description: >
Throws when IdentifierReference is undefined
negative: ReferenceError
---*/
var o = {notDefined};
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 12.2.5
description: >
property names `eval` and `arguments`
---*/
var o = {
eval() {
return 1;
},
arguments() {
return 2;
},
};
assert.sameValue(o.eval(), 1, "`o.eval()` returns `1`");
assert.sameValue(o.arguments(), 2, "`o.arguments()` returns `2`");
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 12.2.5
description: >
super method calls in object literal setters
---*/
var proto = {
_x: 0,
set x(v) {
return this._x = v;
}
};
var object = {
set x(v) {
super.x = v;
}
};
Object.setPrototypeOf(object, proto);
assert.sameValue(object.x = 1, 1, "`object.x = 1` is `1`, after executing `Object.setPrototypeOf(object, proto);`");
assert.sameValue(object._x, 1, "The value of `object._x` is `1`, after executing `Object.setPrototypeOf(object, proto);`");
assert.sameValue(
Object.getPrototypeOf(object)._x,
0,
"The value of `Object.getPrototypeOf(object)._x` is `0`"
);
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 12.2.5
description: >
In non-strict mode, yield is a valid Identifier.
flags: [noStrict]
---*/
var yield = 1;
var object = {yield};
assert.sameValue(object.yield, 1, "The value of `object.yield` is `1`");
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 12.2.5
description: >
In non-strict mode, yield is a valid Identifier.
flags: [noStrict]
---*/
var yield = 1;
var object = {yield};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment