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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 assertEquals("\u1234", fcc(0x1234)); | 59 assertEquals("\u1234", fcc(0x1234)); |
60 assertEquals("\u1234", fcc(0x1234 + 0x10000)); | 60 assertEquals("\u1234", fcc(0x1234 + 0x10000)); |
61 assertEquals("\u1234", fcc(0x1234 - 0x10000)); | 61 assertEquals("\u1234", fcc(0x1234 - 0x10000)); |
62 assertEquals("\u1234", fcc(0x1234 + 0.5)); | 62 assertEquals("\u1234", fcc(0x1234 + 0.5)); |
63 | 63 |
64 assertEquals(" ", fcc(0x20, 0x20)); | 64 assertEquals(" ", fcc(0x20, 0x20)); |
65 assertEquals(" ", fcc(0x20 + 0.5, 0x20)); | 65 assertEquals(" ", fcc(0x20 + 0.5, 0x20)); |
66 | 66 |
67 var receiver = (num < 5) ? String : (num < 9) ? "dummy" : 42; | 67 var receiver = (num < 5) ? String : (num < 9) ? "dummy" : 42; |
68 fcc2 = (num < 5) ? fcc : (num < 9) ? constFun("dummy") : constFun(42); | 68 fcc2 = (num < 5) ? fcc |
69 var expected = (num < 5) ? " " : (num < 9) ? "dummy" : 42; | 69 : (num < 9) ? constFun(Object("dummy")) |
| 70 : constFun(Object(42)); |
| 71 var expected = (num < 5) ? " " : (num < 9) ? Object("dummy") : Object(42); |
70 assertEquals(expected, receiver.fromCharCode(0x20)); | 72 assertEquals(expected, receiver.fromCharCode(0x20)); |
71 assertEquals(expected, receiver.fromCharCode(0x20 - 0x10000)); | 73 assertEquals(expected, receiver.fromCharCode(0x20 - 0x10000)); |
72 assertEquals(expected, receiver.fromCharCode(0x20 + 0.5)); | 74 assertEquals(expected, receiver.fromCharCode(0x20 + 0.5)); |
73 assertEquals(expected, fcc2(0x20)); | 75 assertEquals(expected, fcc2(0x20)); |
74 assertEquals(expected, fcc2(0x20 - 0x10000)); | 76 assertEquals(expected, fcc2(0x20 - 0x10000)); |
75 assertEquals(expected, fcc2(0x20 + 0.5)); | 77 assertEquals(expected, fcc2(0x20 + 0.5)); |
76 } | 78 } |
77 | 79 |
78 // Use loop to test the custom IC. | 80 // Use loop to test the custom IC. |
79 for (var i = 0; i < 10; i++) { | 81 for (var i = 0; i < 10; i++) { |
80 test(i); | 82 test(i); |
81 } | 83 } |
82 | 84 |
83 | 85 |
84 // Test the custom IC works correctly when the map changes. | 86 // Test the custom IC works correctly when the map changes. |
85 for (var i = 0; i < 10; i++) { | 87 for (var i = 0; i < 10; i++) { |
86 var expected = (i < 5) ? " " : 42; | 88 var expected = (i < 5) ? " " : 42; |
87 if (i == 5) String.fromCharCode = function() { return 42; }; | 89 if (i == 5) String.fromCharCode = function() { return 42; }; |
88 assertEquals(expected, String.fromCharCode(0x20)); | 90 assertEquals(expected, String.fromCharCode(0x20)); |
89 } | 91 } |
OLD | NEW |