2011-09-07 08:35:18 +02:00
|
|
|
// Copyright 2009 the Sputnik authors. All rights reserved.
|
|
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
|
2014-07-22 01:09:02 +02:00
|
|
|
/*---
|
2018-01-05 18:26:51 +01:00
|
|
|
info: |
|
2014-07-22 01:09:02 +02:00
|
|
|
ToObject conversion from Object: The result is the input
|
|
|
|
argument (no conversion)
|
2014-07-25 00:41:42 +02:00
|
|
|
es5id: 9.9_A6
|
2014-07-22 01:09:02 +02:00
|
|
|
description: Converting from Objects to Object
|
|
|
|
---*/
|
2011-09-07 08:35:18 +02:00
|
|
|
|
2018-02-15 21:33:45 +01:00
|
|
|
function MyObject(val) {
|
|
|
|
this.value = val;
|
|
|
|
this.valueOf = function() {
|
|
|
|
return this.value;
|
|
|
|
}
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var x = new MyObject(1);
|
|
|
|
var y = Object(x);
|
|
|
|
|
|
|
|
// CHECK#1
|
2018-02-15 21:33:45 +01:00
|
|
|
if (y.valueOf() !== x.valueOf()) {
|
2021-07-28 22:50:06 +02:00
|
|
|
throw new Test262Error('#1: Object(obj).valueOf() === obj.valueOf(). Actual: ' + (Object(obj).valueOf()));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#2
|
2018-02-15 21:33:45 +01:00
|
|
|
if (typeof y !== typeof x) {
|
2021-07-28 22:50:06 +02:00
|
|
|
throw new Test262Error('#2: typeof Object(obj) === typeof obj. Actual: ' + (typeof Object(obj)));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#3
|
2018-02-15 21:33:45 +01:00
|
|
|
if (y.constructor.prototype !== x.constructor.prototype) {
|
2021-07-28 22:50:06 +02:00
|
|
|
throw new Test262Error('#3: Object(obj).constructor.prototype === obj.constructor.prototype. Actual: ' + (Object(obj).constructor.prototype));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// CHECK#4
|
2018-02-15 21:33:45 +01:00
|
|
|
if (y !== x) {
|
2021-07-28 22:50:06 +02:00
|
|
|
throw new Test262Error('#4: Object(obj) === obj');
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|