| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #library('core'); | 5 #library('core'); |
| 6 | 6 |
| 7 #import('coreimpl.dart'); | 7 #import('coreimpl.dart'); |
| 8 | 8 |
| 9 #import('js_helper.dart'); // TODO(ahe): remove this import. | 9 #import('js_helper.dart'); // TODO(ahe): remove this import. |
| 10 | 10 |
| 11 #source('../../../corelib/src/bool.dart'); | 11 #source('../../../corelib/src/bool.dart'); |
| 12 #source('../../../corelib/src/collection.dart'); | 12 #source('../../../corelib/src/collection.dart'); |
| 13 #source('../../../corelib/src/comparable.dart'); | 13 #source('../../../corelib/src/comparable.dart'); |
| 14 #source('../../../corelib/src/date.dart'); | 14 #source('../../../corelib/src/date.dart'); |
| 15 #source('../../../corelib/src/double.dart'); | 15 #source('../../../corelib/src/double.dart'); |
| 16 #source('../../../corelib/src/duration.dart'); | 16 #source('../../../corelib/src/duration.dart'); |
| 17 // #source('../../../corelib/src/exceptions.dart'); | 17 // #source('../../../corelib/src/exceptions.dart'); |
| 18 // #source('../../../corelib/src/expect.dart'); | 18 #source('../../../corelib/src/expect.dart'); |
| 19 #source('../../../corelib/src/function.dart'); | 19 #source('../../../corelib/src/function.dart'); |
| 20 #source('../../../corelib/src/future.dart'); | 20 #source('../../../corelib/src/future.dart'); |
| 21 #source('../../../corelib/src/hashable.dart'); | 21 #source('../../../corelib/src/hashable.dart'); |
| 22 #source('../../../corelib/src/int.dart'); | 22 #source('../../../corelib/src/int.dart'); |
| 23 #source('../../../corelib/src/isolate.dart'); | 23 #source('../../../corelib/src/isolate.dart'); |
| 24 #source('../../../corelib/src/iterable.dart'); | 24 #source('../../../corelib/src/iterable.dart'); |
| 25 #source('../../../corelib/src/iterator.dart'); | 25 #source('../../../corelib/src/iterator.dart'); |
| 26 // #source('../../../corelib/src/list.dart'); | 26 // #source('../../../corelib/src/list.dart'); |
| 27 #source('../../../corelib/src/map.dart'); | 27 #source('../../../corelib/src/map.dart'); |
| 28 #source('../../../corelib/src/math.dart'); | 28 #source('../../../corelib/src/math.dart'); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 57 String toString() { | 57 String toString() { |
| 58 return "NoSuchMethodException - receiver: '$receiver'" + | 58 return "NoSuchMethodException - receiver: '$receiver'" + |
| 59 "function name: '$name' arguments: [$args]"; | 59 "function name: '$name' arguments: [$args]"; |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 | 62 |
| 63 class List<T> implements Iterable<T> { | 63 class List<T> implements Iterable<T> { |
| 64 factory List([int length]) => Primitives.newList(length); | 64 factory List([int length]) => Primitives.newList(length); |
| 65 } | 65 } |
| 66 | 66 |
| 67 class Expect { | 67 interface Exception {} |
| 68 // TODO(ngeoffray): add optional message parameters to these | |
| 69 // methods. | |
| 70 static void equals(var expected, var actual) { | |
| 71 if (expected == actual) return; | |
| 72 _fail('Expect.equals(expected: <$expected>, actual:<$actual> fails.'); | |
| 73 } | |
| 74 | |
| 75 static void fail(String message) { | |
| 76 _fail("Expect.fail('$message')"); | |
| 77 } | |
| 78 | |
| 79 static void _fail(String message) { | |
| 80 throw message; | |
| 81 } | |
| 82 | |
| 83 static void isTrue(var actual) { | |
| 84 if (actual === true) return; | |
| 85 _fail("Expect.isTrue($actual) fails."); | |
| 86 } | |
| 87 | |
| 88 static void isFalse(var actual) { | |
| 89 if (actual === false) return; | |
| 90 _fail("Expect.isFalse($actual) fails."); | |
| 91 } | |
| 92 | |
| 93 static void listEquals(List expected, List actual) { | |
| 94 // We check on length at the end in order to provide better error | |
| 95 // messages when an unexpected item is inserted in a list. | |
| 96 if (expected.length != actual.length) { | |
| 97 _fail('list not equals'); | |
| 98 } | |
| 99 | |
| 100 for (int i = 0; i < expected.length; i++) { | |
| 101 if (expected[i] != actual[i]) { | |
| 102 _fail('list not equals'); | |
| 103 } | |
| 104 } | |
| 105 } | |
| 106 } | |
| 107 | 68 |
| 108 class Stopwatch { | 69 class Stopwatch { |
| 109 double startMs; | 70 double startMs; |
| 110 double elapsedMs; | 71 double elapsedMs; |
| 111 | 72 |
| 112 Stopwatch() { | 73 Stopwatch() { |
| 113 elapsedMs = 0.0; | 74 elapsedMs = 0.0; |
| 114 } | 75 } |
| 115 | 76 |
| 116 void start() { | 77 void start() { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 144 return Primitives.mathFloor(elapsedMs); | 105 return Primitives.mathFloor(elapsedMs); |
| 145 } else { | 106 } else { |
| 146 return Primitives.mathFloor(elapsedMs + (Primitives.dateNow() - startMs)); | 107 return Primitives.mathFloor(elapsedMs + (Primitives.dateNow() - startMs)); |
| 147 } | 108 } |
| 148 } | 109 } |
| 149 | 110 |
| 150 int frequency() { | 111 int frequency() { |
| 151 return 1000; | 112 return 1000; |
| 152 } | 113 } |
| 153 } | 114 } |
| OLD | NEW |