OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2010 the V8 project authors. All rights reserved. | |
2 // Redistribution and use in source and binary forms, with or without | |
3 // modification, are permitted provided that the following conditions are | |
4 // met: | |
5 // | |
6 // * Redistributions of source code must retain the above copyright | |
7 // notice, this list of conditions and the following disclaimer. | |
8 // * Redistributions in binary form must reproduce the above | |
9 // copyright notice, this list of conditions and the following | |
10 // disclaimer in the documentation and/or other materials provided | |
11 // with the distribution. | |
12 // * Neither the name of Google Inc. nor the names of its | |
13 // contributors may be used to endorse or promote products derived | |
14 // from this software without specific prior written permission. | |
15 // | |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
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. | |
27 | |
28 | |
29 // Flags: --expose-natives_as natives | |
30 // Test the SameValue internal method. | |
31 | |
32 var obj1 = {x: 10, y: 11, z: "test"}; | |
33 var obj2 = {x: 10, y: 11, z: "test"}; | |
34 | |
35 assertTrue(natives.SameValue(0, 0)); | |
Erik Corry
2010/05/25 10:29:37
Shouldn't we have +-0 here too for completeness?
Rico
2010/05/25 10:35:58
Done
| |
36 assertTrue(natives.SameValue(1, 1)); | |
37 assertTrue(natives.SameValue(2, 2)); | |
38 assertTrue(natives.SameValue(-1, -1)); | |
39 assertTrue(natives.SameValue(0.5, 0.5)); | |
40 assertTrue(natives.SameValue(true, true)); | |
41 assertTrue(natives.SameValue(false, false)); | |
42 assertTrue(natives.SameValue(NaN, NaN)); | |
43 assertTrue(natives.SameValue(null, null)); | |
44 assertTrue(natives.SameValue("foo", "foo")); | |
45 assertTrue(natives.SameValue(obj1, obj1)); | |
46 // Undefined values. | |
47 assertTrue(natives.SameValue()); | |
48 assertTrue(natives.SameValue(undefined, undefined)); | |
49 | |
50 assertFalse(natives.SameValue(0,1)); | |
51 assertFalse(natives.SameValue("foo", "bar")); | |
52 assertFalse(natives.SameValue(obj1, obj2)); | |
53 assertFalse(natives.SameValue(true, false)); | |
54 | |
55 assertFalse(natives.SameValue(obj1, true)); | |
56 assertFalse(natives.SameValue(obj1, "foo")); | |
57 assertFalse(natives.SameValue(obj1, 1)); | |
58 assertFalse(natives.SameValue(obj1, undefined)); | |
59 assertFalse(natives.SameValue(obj1, NaN)); | |
60 | |
61 assertFalse(natives.SameValue(undefined, true)); | |
62 assertFalse(natives.SameValue(undefined, "foo")); | |
63 assertFalse(natives.SameValue(undefined, 1)); | |
64 assertFalse(natives.SameValue(undefined, obj1)); | |
65 assertFalse(natives.SameValue(undefined, NaN)); | |
66 | |
67 assertFalse(natives.SameValue(NaN, true)); | |
68 assertFalse(natives.SameValue(NaN, "foo")); | |
69 assertFalse(natives.SameValue(NaN, 1)); | |
70 assertFalse(natives.SameValue(NaN, obj1)); | |
71 assertFalse(natives.SameValue(NaN, undefined)); | |
72 | |
73 assertFalse(natives.SameValue("foo", true)); | |
74 assertFalse(natives.SameValue("foo", 1)); | |
75 assertFalse(natives.SameValue("foo", obj1)); | |
76 assertFalse(natives.SameValue("foo", undefined)); | |
77 assertFalse(natives.SameValue("foo", NaN)); | |
78 | |
79 assertFalse(natives.SameValue(true, 1)); | |
80 assertFalse(natives.SameValue(true, obj1)); | |
81 assertFalse(natives.SameValue(true, undefined)); | |
82 assertFalse(natives.SameValue(true, NaN)); | |
83 assertFalse(natives.SameValue(true, "foo")); | |
84 | |
85 assertFalse(natives.SameValue(1, true)); | |
86 assertFalse(natives.SameValue(1, obj1)); | |
87 assertFalse(natives.SameValue(1, undefined)); | |
88 assertFalse(natives.SameValue(1, NaN)); | |
89 assertFalse(natives.SameValue(1, "foo")); | |
90 | |
91 // Special string cases. | |
92 assertFalse(natives.SameValue("1", 1)); | |
93 assertFalse(natives.SameValue("true", true)); | |
94 assertFalse(natives.SameValue("false", false)); | |
95 assertFalse(natives.SameValue("undefined", undefined)); | |
96 assertFalse(natives.SameValue("NaN", NaN)); | |
97 | |
OLD | NEW |