Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: tests/corelib/integer_to_string_test.dart

Issue 211223002: Add MapBase and UnmodifiableMapView classes to dart:collection. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 main() { 7 main() {
8 /// Test that converting [value] to a string gives [expect]. 8 /// Test that converting [value] to a string gives [expect].
9 /// Also test that `-value` gives `"-"+expect`. 9 /// Also test that `-value` gives `"-"+expect`.
10 test(int value, String expect) { 10 test(int value, String expect) {
11 Expect.equals(expect, value.toString()); 11 Expect.equals(expect, value.toString());
12 Expect.equals(expect, "$value"); 12 Expect.equals(expect, "$value");
13 Expect.equals(expect, (new StringBuffer()..write(value)).toString()); 13 Expect.equals(expect, (new StringBuffer()..write(value)).toString());
14 if (value == 0) return; 14 if (value == 0) return;
15 expect = "-$expect"; 15 expect = "-$expect";
16 value = -value; 16 value = -value;
17 Expect.equals(expect, value.toString()); 17 Expect.equals(expect, value.toString());
18 Expect.equals(expect, "$value"); 18 Expect.equals(expect, "$value");
19 Expect.equals(expect, (new StringBuffer()..write(value)).toString()); 19 Expect.equals(expect, (new StringBuffer()..write(value)).toString());
20 } 20 }
21 21
22 // Null. 22 // Very simple tests.
23 test(0, "0"); 23 test(0, "0");
24 test(1, "1"); 24 test(1, "1");
25 test(2, "2"); 25 test(2, "2");
26 test(5, "5"); 26 test(5, "5");
27 27
28 // Binary special cases. 28 // Binary special cases.
29 29
30 // ~2^30. 30 // ~2^30.
31 test(0x3fffffff, "1073741823"); 31 test(0x3fffffff, "1073741823");
32 test(0x40000000, "1073741824"); 32 test(0x40000000, "1073741824");
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 number *= 10; 79 number *= 10;
80 } 80 }
81 // Fails to represent exactly in dart2js. 81 // Fails to represent exactly in dart2js.
82 for (int i = 15; i < 22; i++) { /// 01: continued 82 for (int i = 15; i < 22; i++) { /// 01: continued
83 test(number - 1, "9" * i); /// 01: continued 83 test(number - 1, "9" * i); /// 01: continued
84 test(number, "1" + "0" * i); /// 01: continued 84 test(number, "1" + "0" * i); /// 01: continued
85 test(number + 1, "1" + "0" * (i - 1) + "1"); /// 01: continued 85 test(number + 1, "1" + "0" * (i - 1) + "1"); /// 01: continued
86 number *= 10; /// 01: continued 86 number *= 10; /// 01: continued
87 } /// 01: continued 87 } /// 01: continued
88 } 88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698