| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 void print(var obj) { | 5 void print(var obj) { |
| 6 // TODO(ngeoffray): enable when the parser accepts it. | 6 // TODO(ngeoffray): enable when the parser accepts it. |
| 7 // obj = obj.toString(); | 7 // obj = obj.toString(); |
| 8 var hasConsole = JS("bool", @"typeof console == 'object'"); | 8 var hasConsole = JS("bool", @"typeof console == 'object'"); |
| 9 if (hasConsole) { | 9 if (hasConsole) { |
| 10 JS("void", @"console.log($0)", obj); | 10 JS("void", @"console.log($0)", obj); |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 '>, actual:<' + actual.toString() + '> fails.'); | 328 '>, actual:<' + actual.toString() + '> fails.'); |
| 329 } | 329 } |
| 330 | 330 |
| 331 static void fail(String message) { | 331 static void fail(String message) { |
| 332 _fail("Expect.fail('" + message + "')"); | 332 _fail("Expect.fail('" + message + "')"); |
| 333 } | 333 } |
| 334 | 334 |
| 335 static void _fail(String message) { | 335 static void _fail(String message) { |
| 336 throw message; | 336 throw message; |
| 337 } | 337 } |
| 338 |
| 339 static void isTrue(var actual) { |
| 340 if (actual === true) return; |
| 341 _fail("Expect.isTrue($actual) fails."); |
| 342 } |
| 338 } | 343 } |
| 339 | 344 |
| 340 class Stopwatch { | 345 class Stopwatch { |
| 341 double startMs; | 346 double startMs; |
| 342 double elapsedMs; | 347 double elapsedMs; |
| 343 | 348 |
| 344 Stopwatch() { | 349 Stopwatch() { |
| 345 elapsedMs = 0.0; | 350 elapsedMs = 0.0; |
| 346 } | 351 } |
| 347 | 352 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 377 } else { | 382 } else { |
| 378 return | 383 return |
| 379 JS("num", @"Math.floor($0 + (Date.now() - $1))", elapsedMs, startMs); | 384 JS("num", @"Math.floor($0 + (Date.now() - $1))", elapsedMs, startMs); |
| 380 } | 385 } |
| 381 } | 386 } |
| 382 | 387 |
| 383 int frequency() { | 388 int frequency() { |
| 384 return 1000; | 389 return 1000; |
| 385 } | 390 } |
| 386 } | 391 } |
| OLD | NEW |