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

Side by Side Diff: pkg/fixnum/test/int_64_test.dart

Issue 34223002: Throw FormatException when Int32/Int64.parseRadix() encounters bad digit (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Throw FormatException when Int32/Int64.parseRadix() encounters bad digit Created 7 years, 1 month 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
« no previous file with comments | « pkg/fixnum/test/int_32_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library int64test; 5 library int64test;
6 import 'package:fixnum/fixnum.dart'; 6 import 'package:fixnum/fixnum.dart';
7 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 8
9 void main() { 9 void main() {
10 group("is-tests", () { 10 group("is-tests", () {
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 return new Int64(1); 627 return new Int64(1);
628 } else { 628 } else {
629 return n * _factorial(n - new Int64(1)); 629 return n * _factorial(n - new Int64(1));
630 } 630 }
631 } 631 }
632 Int64 fact18 = _factorial(new Int64(18)); 632 Int64 fact18 = _factorial(new Int64(18));
633 Int64 fact17 = _factorial(new Int64(17)); 633 Int64 fact17 = _factorial(new Int64(17));
634 expect(fact18 ~/ fact17, new Int64(18)); 634 expect(fact18 ~/ fact17, new Int64(18));
635 }); 635 });
636 636
637 test("min, max values", () { 637 test("min, max values", () { expect(new Int64(1) << 63, Int64.MIN_VALUE);
sra1 2013/10/23 04:09:11 Put the first statement of the block back on its o
Chris Bracken 2013/10/23 23:34:12 Done.
638 expect(new Int64(1) << 63, Int64.MIN_VALUE);
639 expect(-(Int64.MIN_VALUE + new Int64(1)), Int64.MAX_VALUE); 638 expect(-(Int64.MIN_VALUE + new Int64(1)), Int64.MAX_VALUE);
640 }); 639 });
641 640
642 group("parse", () { 641 group("parse", () {
643 test("parseRadix10", () { 642 test("parseRadix10", () {
644 checkInt(int x) { 643 checkInt(int x) {
645 expect(Int64.parseRadix('$x', 10), new Int64(x)); 644 expect(Int64.parseRadix('$x', 10), new Int64(x));
646 } 645 }
647 checkInt(0); 646 checkInt(0);
648 checkInt(1); 647 checkInt(1);
649 checkInt(-1); 648 checkInt(-1);
650 checkInt(1000); 649 checkInt(1000);
651 checkInt(12345678); 650 checkInt(12345678);
652 checkInt(-12345678); 651 checkInt(-12345678);
653 checkInt(2147483647); 652 checkInt(2147483647);
654 checkInt(2147483648); 653 checkInt(2147483648);
655 checkInt(-2147483647); 654 checkInt(-2147483647);
656 checkInt(-2147483648); 655 checkInt(-2147483648);
657 checkInt(4294967295); 656 checkInt(4294967295);
658 checkInt(4294967296); 657 checkInt(4294967296);
659 checkInt(-4294967295); 658 checkInt(-4294967295);
660 checkInt(-4294967296); 659 checkInt(-4294967296);
660 expect(() => Int64.parseRadix('xyzzy', -1), throwsArgumentError);
661 expect(() => Int64.parseRadix('plugh', 10),
662 throwsA(new isInstanceOf<FormatException>()));
661 }); 663 });
662 664
663 test("parseRadix", () { 665 test("parseRadix", () {
664 check(String s, int r, String x) { 666 check(String s, int r, String x) {
665 expect(Int64.parseRadix(s, r).toString(), x); 667 expect(Int64.parseRadix(s, r).toString(), x);
666 } 668 }
667 check('ghoul', 36, '27699213'); 669 check('ghoul', 36, '27699213');
668 check('ghoul', 35, '24769346'); 670 check('ghoul', 35, '24769346');
669 // Min and max value. 671 // Min and max value.
670 check("-9223372036854775808", 10, "-9223372036854775808"); 672 check("-9223372036854775808", 10, "-9223372036854775808");
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 expect(Int64.MAX_VALUE.toRadixString(10), "9223372036854775807"); 744 expect(Int64.MAX_VALUE.toRadixString(10), "9223372036854775807");
743 expect(Int64.MAX_VALUE.toRadixString(11), "1728002635214590697"); 745 expect(Int64.MAX_VALUE.toRadixString(11), "1728002635214590697");
744 expect(Int64.MAX_VALUE.toRadixString(12), "41a792678515120367"); 746 expect(Int64.MAX_VALUE.toRadixString(12), "41a792678515120367");
745 expect(Int64.MAX_VALUE.toRadixString(13), "10b269549075433c37"); 747 expect(Int64.MAX_VALUE.toRadixString(13), "10b269549075433c37");
746 expect(Int64.MAX_VALUE.toRadixString(14), "4340724c6c71dc7a7"); 748 expect(Int64.MAX_VALUE.toRadixString(14), "4340724c6c71dc7a7");
747 expect(Int64.MAX_VALUE.toRadixString(15), "160e2ad3246366807"); 749 expect(Int64.MAX_VALUE.toRadixString(15), "160e2ad3246366807");
748 expect(Int64.MAX_VALUE.toRadixString(16), "7fffffffffffffff"); 750 expect(Int64.MAX_VALUE.toRadixString(16), "7fffffffffffffff");
749 }); 751 });
750 }); 752 });
751 } 753 }
OLDNEW
« no previous file with comments | « pkg/fixnum/test/int_32_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698