OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 })()"; | 62 })()"; |
63 assertEquals(8, eval(code)); | 63 assertEquals(8, eval(code)); |
64 | 64 |
65 | 65 |
66 code = "(function() {\ | 66 code = "(function() {\ |
67 var x,y,z;\ | 67 var x,y,z;\ |
68 return x = y = z = 8;\ | 68 return x = y = z = 8;\ |
69 })()"; | 69 })()"; |
70 assertEquals(8, eval(code)); | 70 assertEquals(8, eval(code)); |
71 | 71 |
| 72 // Test object literals. |
| 73 var a, b; |
| 74 a = {x:8}; |
| 75 assertEquals(8, a.x); |
| 76 |
| 77 b = {x:a, y:"abc"}; |
| 78 assertEquals(a, b.x); |
| 79 assertEquals(8, b.x.x); |
| 80 assertEquals("abc", b.y); |
| 81 |
| 82 code = "({x:8, y:9}); 10"; |
| 83 assertEquals(10, eval(code)); |
| 84 |
| 85 code = "({x:8, y:9})"; |
| 86 assertEquals(9, eval(code+".y")); |
| 87 |
| 88 a = {2:8, x:9}; |
| 89 assertEquals(8, a[2]); |
| 90 assertEquals(8, a["2"]); |
| 91 assertEquals(9, a["x"]); |
| 92 |
| 93 // Test regexp literals. |
| 94 |
| 95 a = /abc/; |
| 96 |
| 97 assertEquals(/abc/, a); |
| 98 |
| 99 code = "/abc/; 8"; |
| 100 assertEquals(8, eval(code)); |
OLD | NEW |