js/src/tests/test262/ch09/9.9/S9.9_A6.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/test262/ch09/9.9/S9.9_A6.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,40 @@
     1.4 +// Copyright 2009 the Sputnik authors.  All rights reserved.
     1.5 +// This code is governed by the BSD license found in the LICENSE file.
     1.6 +
     1.7 +/**
     1.8 + * ToObject conversion from Object: The result is the input
     1.9 + * argument (no conversion)
    1.10 + *
    1.11 + * @path ch09/9.9/S9.9_A6.js
    1.12 + * @description Converting from Objects to Object
    1.13 + */
    1.14 +
    1.15 +function MyObject( val ) {
    1.16 +    this.value = val;
    1.17 +    this.valueOf = function (){ return this.value; }
    1.18 +}
    1.19 +
    1.20 +var x = new MyObject(1);
    1.21 +var y = Object(x);
    1.22 +
    1.23 +// CHECK#1
    1.24 +if (y.valueOf() !== x.valueOf()){
    1.25 +  $ERROR('#1: Object(obj).valueOf() === obj.valueOf(). Actual: ' + (Object(obj).valueOf()));
    1.26 +}
    1.27 +
    1.28 +// CHECK#2
    1.29 +if (typeof y !== typeof x){
    1.30 +  $ERROR('#2: typeof Object(obj) === typeof obj. Actual: ' + (typeof Object(obj)));
    1.31 +}
    1.32 +
    1.33 +// CHECK#3
    1.34 +if (y.constructor.prototype !== x.constructor.prototype){
    1.35 +  $ERROR('#3: Object(obj).constructor.prototype === obj.constructor.prototype. Actual: ' + (Object(obj).constructor.prototype));
    1.36 +}
    1.37 +
    1.38 +
    1.39 +// CHECK#4
    1.40 +if (y !== x){
    1.41 +  $ERROR('#4: Object(obj) === obj');
    1.42 +}
    1.43 +

mercurial