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

Unified Diff: pkg/math/test/invert_test.dart

Issue 475463005: Implement math.gcd in dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweaks Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/math/test/gcdext_test.dart ('k') | pkg/math/test/lcm_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/math/test/invert_test.dart
diff --git a/pkg/math/test/invert_test.dart b/pkg/math/test/invert_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..75cac9f8cdb35e60925b1f93f597c2878ca5dfba
--- /dev/null
+++ b/pkg/math/test/invert_test.dart
@@ -0,0 +1,32 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library math_test;
+import "package:expect/expect.dart";
+import 'dart:math';
+import 'package:math/math.dart';
+
+void testInvert() {
+ Expect.equals(1, invert(1, 7));
+ Expect.equals(4, invert(2, 7));
+ Expect.equals(5, invert(3, 7));
+ Expect.equals(2, invert(4, 7));
+ Expect.equals(3, invert(5, 7));
+ Expect.equals(6, invert(6, 7));
+
+ Expect.throws(() => invert(0, null), (e) => e is ArgumentError);
+ Expect.throws(() => invert(null, 0), (e) => e is ArgumentError);
+ Expect.throws(() => invert(0, 7), (e) => e is IntegerDivisionByZeroException);
+ Expect.throws(() => invert(3, 6), (e) => e is IntegerDivisionByZeroException);
+ Expect.throws(() => invert(6, 3), (e) => e is IntegerDivisionByZeroException);
+ Expect.throws(() => invert(6, 0), (e) => e is IntegerDivisionByZeroException);
+
+ // Medium int (mint) arguments.
+ Expect.equals(7291109880702, invert(1000, 9079837958533));
+ Expect.equals(6417656708605, invert(1000000, 9079837958533));
+}
+
+main() {
+ testInvert();
+}
« no previous file with comments | « pkg/math/test/gcdext_test.dart ('k') | pkg/math/test/lcm_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698