| 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 obj = obj.toString(); | 6 obj = obj.toString(); |
| 7 var hasConsole = JS("bool", @"typeof console == 'object'"); | 7 var hasConsole = JS("bool", @"typeof console == 'object'"); |
| 8 if (hasConsole) { | 8 if (hasConsole) { |
| 9 JS("void", @"console.log($0)", obj); | 9 JS("void", @"console.log($0)", obj); |
| 10 } else { | 10 } else { |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 // TODO(ngeoffray): Adjust to optional parameters. | 329 // TODO(ngeoffray): Adjust to optional parameters. |
| 330 if (JS("bool", @"$0 === (void 0)", n)) return JS("Object", @"new Array()"); | 330 if (JS("bool", @"$0 === (void 0)", n)) return JS("Object", @"new Array()"); |
| 331 _checkConstructorInput(n); | 331 _checkConstructorInput(n); |
| 332 return JS("Object", @"new Array($0)", n); | 332 return JS("Object", @"new Array($0)", n); |
| 333 } | 333 } |
| 334 } | 334 } |
| 335 | 335 |
| 336 class ListIterator<T> /* implements Iterator<T> */ { | 336 class ListIterator<T> /* implements Iterator<T> */ { |
| 337 int i; | 337 int i; |
| 338 List<T> list; | 338 List<T> list; |
| 339 ListIterator(List<T> list) : this.list = list, i = 0; | 339 ListIterator(List<T> this.list) : i = 0; |
| 340 bool hasNext() => i < JS("int", @"$0.length", list); | 340 bool hasNext() => i < JS("int", @"$0.length", list); |
| 341 T next() { | 341 T next() { |
| 342 var value = JS("Object", @"$0[$1]", list, i); | 342 var value = JS("Object", @"$0[$1]", list, i); |
| 343 i += 1; | 343 i += 1; |
| 344 return value; | 344 return value; |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 | 347 |
| 348 class Expect { | 348 class Expect { |
| 349 static void equals(var expected, var actual) { | 349 static void equals(var expected, var actual) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } else { | 405 } else { |
| 406 return | 406 return |
| 407 JS("num", @"Math.floor($0 + (Date.now() - $1))", elapsedMs, startMs); | 407 JS("num", @"Math.floor($0 + (Date.now() - $1))", elapsedMs, startMs); |
| 408 } | 408 } |
| 409 } | 409 } |
| 410 | 410 |
| 411 int frequency() { | 411 int frequency() { |
| 412 return 1000; | 412 return 1000; |
| 413 } | 413 } |
| 414 } | 414 } |
| OLD | NEW |