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);
|
|
|
|
|
2021-08-12 22:28:19 +02:00
|
|
|
assert.sameValue(y.valueOf(), x.valueOf(), 'y.valueOf() must return the same value returned by x.valueOf()');
|
|
|
|
assert.sameValue(typeof y, typeof x, 'The value of `typeof y` is expected to be typeof x');
|
2011-09-07 08:35:18 +02:00
|
|
|
|
2021-08-12 22:28:19 +02:00
|
|
|
assert.sameValue(
|
|
|
|
y.constructor.prototype,
|
|
|
|
x.constructor.prototype,
|
|
|
|
'The value of y.constructor.prototype is expected to equal the value of x.constructor.prototype'
|
|
|
|
);
|
2011-09-07 08:35:18 +02:00
|
|
|
|
2021-08-12 22:28:19 +02:00
|
|
|
assert.sameValue(y, x, 'The value of y is expected to equal the value of x');
|