Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 34 function testDateParse(string) { | 34 function testDateParse(string) { |
| 35 var d = Date.parse(string); | 35 var d = Date.parse(string); |
| 36 assertEquals(946713600000, d, string); | 36 assertEquals(946713600000, d, string); |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 | 39 |
| 40 // For local time we just test that parsing returns non-NaN positive | 40 // For local time we just test that parsing returns non-NaN positive |
| 41 // number of milliseconds to make it timezone independent. | 41 // number of milliseconds to make it timezone independent. |
| 42 function testDateParseLocalTime(string) { | 42 function testDateParseLocalTime(string) { |
| 43 var d = Date.parse(string); | 43 var d = Date.parse(string); |
| 44 assertTrue(d > 0 && !isNaN(d)); | 44 assertTrue(d > 0 && !isNaN(d), string); |
|
Erik Corry
2009/03/17 13:09:01
This should be two assertions.
| |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 | 47 |
| 48 function testDateParseMisc(array) { | 48 function testDateParseMisc(array) { |
| 49 assertTrue(array.length == 2); | 49 assertTrue(array.length == 2, "array [" + array + "] length != 2"); |
|
Erik Corry
2009/03/17 13:09:01
This should be assertEquals(2, array.length, ...)
| |
| 50 var string = array[0]; | 50 var string = array[0]; |
| 51 var expected = array[1]; | 51 var expected = array[1]; |
| 52 var d = Date.parse(string); | 52 var d = Date.parse(string); |
| 53 assertEquals(expected, d, string); | 53 assertEquals(expected, d, string); |
| 54 } | 54 } |
| 55 | 55 |
| 56 | 56 |
| 57 // | 57 // |
| 58 // Test all the formats in UT timezone. | 58 // Test all the formats in UT timezone. |
| 59 // | 59 // |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 var s = (new Date(ms)).toString(); | 255 var s = (new Date(ms)).toString(); |
| 256 assertEquals(ms, Date.parse(s), s); | 256 assertEquals(ms, Date.parse(s), s); |
| 257 } | 257 } |
| 258 | 258 |
| 259 // Negative tests. | 259 // Negative tests. |
| 260 var testCasesNegative = [ | 260 var testCasesNegative = [ |
| 261 'May 25 2008 1:30 (PM)) UTC', | 261 'May 25 2008 1:30 (PM)) UTC', |
| 262 'May 25 2008 1:30( )AM (PM)', | 262 'May 25 2008 1:30( )AM (PM)', |
| 263 'May 25 2008 AAA (GMT)']; | 263 'May 25 2008 AAA (GMT)']; |
| 264 | 264 |
| 265 testCasesNegative.forEach(function (s) { assertTrue(isNaN(Date.parse(s))); }); | 265 testCasesNegative.forEach(function (s) { |
| 266 assertTrue(isNaN(Date.parse(s)), s); | |
| 267 }); | |
| OLD | NEW |