| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 | 28 |
| 29 // Flags: --expose-natives_as natives | 29 // Flags: --expose-natives_as natives |
| 30 // Test the SameValue internal method. | 30 // Test the SameValue internal method. |
| 31 | 31 |
| 32 var obj1 = {x: 10, y: 11, z: "test"}; | 32 var obj1 = {x: 10, y: 11, z: "test"}; |
| 33 var obj2 = {x: 10, y: 11, z: "test"}; | 33 var obj2 = {x: 10, y: 11, z: "test"}; |
| 34 | 34 |
| 35 assertTrue(natives.SameValue(0, 0)); | 35 var sameValue = natives.$sameValue; |
| 36 assertTrue(natives.SameValue(+0, +0)); | 36 |
| 37 assertTrue(natives.SameValue(-0, -0)); | 37 assertTrue(sameValue(0, 0)); |
| 38 assertTrue(natives.SameValue(1, 1)); | 38 assertTrue(sameValue(+0, +0)); |
| 39 assertTrue(natives.SameValue(2, 2)); | 39 assertTrue(sameValue(-0, -0)); |
| 40 assertTrue(natives.SameValue(-1, -1)); | 40 assertTrue(sameValue(1, 1)); |
| 41 assertTrue(natives.SameValue(0.5, 0.5)); | 41 assertTrue(sameValue(2, 2)); |
| 42 assertTrue(natives.SameValue(true, true)); | 42 assertTrue(sameValue(-1, -1)); |
| 43 assertTrue(natives.SameValue(false, false)); | 43 assertTrue(sameValue(0.5, 0.5)); |
| 44 assertTrue(natives.SameValue(NaN, NaN)); | 44 assertTrue(sameValue(true, true)); |
| 45 assertTrue(natives.SameValue(null, null)); | 45 assertTrue(sameValue(false, false)); |
| 46 assertTrue(natives.SameValue("foo", "foo")); | 46 assertTrue(sameValue(NaN, NaN)); |
| 47 assertTrue(natives.SameValue(obj1, obj1)); | 47 assertTrue(sameValue(null, null)); |
| 48 assertTrue(sameValue("foo", "foo")); |
| 49 assertTrue(sameValue(obj1, obj1)); |
| 48 // Undefined values. | 50 // Undefined values. |
| 49 assertTrue(natives.SameValue()); | 51 assertTrue(sameValue()); |
| 50 assertTrue(natives.SameValue(undefined, undefined)); | 52 assertTrue(sameValue(undefined, undefined)); |
| 51 | 53 |
| 52 assertFalse(natives.SameValue(0,1)); | 54 assertFalse(sameValue(0,1)); |
| 53 assertFalse(natives.SameValue("foo", "bar")); | 55 assertFalse(sameValue("foo", "bar")); |
| 54 assertFalse(natives.SameValue(obj1, obj2)); | 56 assertFalse(sameValue(obj1, obj2)); |
| 55 assertFalse(natives.SameValue(true, false)); | 57 assertFalse(sameValue(true, false)); |
| 56 | 58 |
| 57 assertFalse(natives.SameValue(obj1, true)); | 59 assertFalse(sameValue(obj1, true)); |
| 58 assertFalse(natives.SameValue(obj1, "foo")); | 60 assertFalse(sameValue(obj1, "foo")); |
| 59 assertFalse(natives.SameValue(obj1, 1)); | 61 assertFalse(sameValue(obj1, 1)); |
| 60 assertFalse(natives.SameValue(obj1, undefined)); | 62 assertFalse(sameValue(obj1, undefined)); |
| 61 assertFalse(natives.SameValue(obj1, NaN)); | 63 assertFalse(sameValue(obj1, NaN)); |
| 62 | 64 |
| 63 assertFalse(natives.SameValue(undefined, true)); | 65 assertFalse(sameValue(undefined, true)); |
| 64 assertFalse(natives.SameValue(undefined, "foo")); | 66 assertFalse(sameValue(undefined, "foo")); |
| 65 assertFalse(natives.SameValue(undefined, 1)); | 67 assertFalse(sameValue(undefined, 1)); |
| 66 assertFalse(natives.SameValue(undefined, obj1)); | 68 assertFalse(sameValue(undefined, obj1)); |
| 67 assertFalse(natives.SameValue(undefined, NaN)); | 69 assertFalse(sameValue(undefined, NaN)); |
| 68 | 70 |
| 69 assertFalse(natives.SameValue(NaN, true)); | 71 assertFalse(sameValue(NaN, true)); |
| 70 assertFalse(natives.SameValue(NaN, "foo")); | 72 assertFalse(sameValue(NaN, "foo")); |
| 71 assertFalse(natives.SameValue(NaN, 1)); | 73 assertFalse(sameValue(NaN, 1)); |
| 72 assertFalse(natives.SameValue(NaN, obj1)); | 74 assertFalse(sameValue(NaN, obj1)); |
| 73 assertFalse(natives.SameValue(NaN, undefined)); | 75 assertFalse(sameValue(NaN, undefined)); |
| 74 | 76 |
| 75 assertFalse(natives.SameValue("foo", true)); | 77 assertFalse(sameValue("foo", true)); |
| 76 assertFalse(natives.SameValue("foo", 1)); | 78 assertFalse(sameValue("foo", 1)); |
| 77 assertFalse(natives.SameValue("foo", obj1)); | 79 assertFalse(sameValue("foo", obj1)); |
| 78 assertFalse(natives.SameValue("foo", undefined)); | 80 assertFalse(sameValue("foo", undefined)); |
| 79 assertFalse(natives.SameValue("foo", NaN)); | 81 assertFalse(sameValue("foo", NaN)); |
| 80 | 82 |
| 81 assertFalse(natives.SameValue(true, 1)); | 83 assertFalse(sameValue(true, 1)); |
| 82 assertFalse(natives.SameValue(true, obj1)); | 84 assertFalse(sameValue(true, obj1)); |
| 83 assertFalse(natives.SameValue(true, undefined)); | 85 assertFalse(sameValue(true, undefined)); |
| 84 assertFalse(natives.SameValue(true, NaN)); | 86 assertFalse(sameValue(true, NaN)); |
| 85 assertFalse(natives.SameValue(true, "foo")); | 87 assertFalse(sameValue(true, "foo")); |
| 86 | 88 |
| 87 assertFalse(natives.SameValue(1, true)); | 89 assertFalse(sameValue(1, true)); |
| 88 assertFalse(natives.SameValue(1, obj1)); | 90 assertFalse(sameValue(1, obj1)); |
| 89 assertFalse(natives.SameValue(1, undefined)); | 91 assertFalse(sameValue(1, undefined)); |
| 90 assertFalse(natives.SameValue(1, NaN)); | 92 assertFalse(sameValue(1, NaN)); |
| 91 assertFalse(natives.SameValue(1, "foo")); | 93 assertFalse(sameValue(1, "foo")); |
| 92 | 94 |
| 93 // Special string cases. | 95 // Special string cases. |
| 94 assertFalse(natives.SameValue("1", 1)); | 96 assertFalse(sameValue("1", 1)); |
| 95 assertFalse(natives.SameValue("true", true)); | 97 assertFalse(sameValue("true", true)); |
| 96 assertFalse(natives.SameValue("false", false)); | 98 assertFalse(sameValue("false", false)); |
| 97 assertFalse(natives.SameValue("undefined", undefined)); | 99 assertFalse(sameValue("undefined", undefined)); |
| 98 assertFalse(natives.SameValue("NaN", NaN)); | 100 assertFalse(sameValue("NaN", NaN)); |
| 99 | 101 |
| 100 // -0 and +0 are should be different | 102 // -0 and +0 are should be different |
| 101 assertFalse(natives.SameValue(+0, -0)); | 103 assertFalse(sameValue(+0, -0)); |
| 102 assertFalse(natives.SameValue(-0, +0)); | 104 assertFalse(sameValue(-0, +0)); |
| OLD | NEW |