| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 // Test text representation | 47 // Test text representation |
| 48 assertEquals(String(n), mirror.toText()); | 48 assertEquals(String(n), mirror.toText()); |
| 49 | 49 |
| 50 // Parse JSON representation and check. | 50 // Parse JSON representation and check. |
| 51 var fromJSON = eval('(' + json + ')'); | 51 var fromJSON = eval('(' + json + ')'); |
| 52 assertEquals('number', fromJSON.type); | 52 assertEquals('number', fromJSON.type); |
| 53 if (!isNaN(n)) { | 53 if (!isNaN(n)) { |
| 54 assertEquals(n, fromJSON.value); | 54 assertEquals(n, fromJSON.value); |
| 55 } else { | 55 } else { |
| 56 assertTrue(isNaN(fromJSON.value)); | 56 // NaN values are encoded as strings. |
| 57 assertTrue(typeof fromJSON.value == 'string'); |
| 58 if (n === Infinity) { |
| 59 assertEquals('Infinity', fromJSON.value); |
| 60 } else if (n === -Infinity) { |
| 61 assertEquals('-Infinity', fromJSON.value); |
| 62 } else { |
| 63 assertEquals('NaN', fromJSON.value); |
| 64 } |
| 57 } | 65 } |
| 58 } | 66 } |
| 59 | 67 |
| 60 | 68 |
| 61 // Test a number of different numbers. | 69 // Test a number of different numbers. |
| 62 testNumberMirror(-7); | 70 testNumberMirror(-7); |
| 63 testNumberMirror(-6.5); | 71 testNumberMirror(-6.5); |
| 64 testNumberMirror(0); | 72 testNumberMirror(0); |
| 65 testNumberMirror(42); | 73 testNumberMirror(42); |
| 66 testNumberMirror(100.0002); | 74 testNumberMirror(100.0002); |
| 67 testNumberMirror(Infinity); | 75 testNumberMirror(Infinity); |
| 68 testNumberMirror(-Infinity); | 76 testNumberMirror(-Infinity); |
| 69 testNumberMirror(NaN); | 77 testNumberMirror(NaN); |
| OLD | NEW |