Chromium Code Reviews| Index: frog/leg/lib/core.dart |
| =================================================================== |
| --- frog/leg/lib/core.dart (revision 2746) |
| +++ frog/leg/lib/core.dart (working copy) |
| @@ -242,12 +242,21 @@ |
| throw "Unimplemented user-defined length."; |
| } |
| +bool isInt(var v) { |
| + return JS(@"($0 | 0) === $1", v, v); |
| +} |
| + |
| class int {} |
| class double {} |
| class String {} |
| class bool {} |
| class Object {} |
| -class List<T> {} |
| +class List<T> { |
| + factory List(int n) { |
| + if (!isInt(n)) throw "Invalid length"; |
|
ahe
2011/12/22 13:32:39
What about negative sizes?
ngeoffray
2011/12/22 13:50:23
Done.
|
| + return JS(@"new Array($0)", n); |
| + } |
| +} |
| class Expect { |
| static void equals(var expected, var actual) { |