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

Side by Side Diff: pkg/math/test/lcm_test.dart

Issue 541523002: pkg/math: remove placeholder (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/math/test/invert_test.dart ('k') | pkg/math/test/powmod_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
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.
4
5 library math_test;
6 import "package:expect/expect.dart";
7 import 'dart:math';
8 import 'package:math/math.dart';
9
10 void testLcm() {
11 Expect.equals(0, lcm(0, 7));
12 Expect.equals(0, lcm(5, 0));
13 Expect.equals(0, lcm(-5, 0));
14 Expect.equals(0, lcm(0, 0));
15 Expect.equals(35, lcm(5, 7));
16 Expect.equals(36, lcm(12, 18));
17 Expect.equals(36, lcm(12, -18));
18 Expect.equals(36, lcm(-12, -18));
19 Expect.equals(36, lcm(18, 12));
20 Expect.equals(315, lcm(45, 105));
21
22 Expect.throws(() => lcm(0, null), (e) => e is ArgumentError);
23 Expect.throws(() => lcm(null, 0), (e) => e is ArgumentError);
24
25 // Cover all branches in Binary GCD implementation.
26 // 0 shared powers-of-two factors.
27 Expect.equals(28, lcm(2*2, 7));
28 // 1 shared power-of-two factor.
29 Expect.equals(28, lcm(2*2, 2*7));
30 // >1 shared powers-of-two factors.
31 Expect.equals(120, lcm(2*2*2*3, 2*2*2*5));
32
33 // 0 remaining powers-of-two in a.
34 Expect.equals(18, lcm(2*3, 2*3*3));
35 // 1 remaining power-of-two in a.
36 Expect.equals(36, lcm(2*2*3, 2*3*3));
37 // >1 remaining powers-of-two in a.
38 Expect.equals(144, lcm(2*2*2*2*3, 2*3*3));
39
40 // 0 remaining powers-of-two in b.
41 Expect.equals(18, lcm(2*3, 2*3*3));
42 // 1 remaining power-of-two in b.
43 Expect.equals(12, lcm(2*3, 2*2*3));
44 // >1 remaining powers-of-two in b.
45 Expect.equals(72, lcm(2*3, 2*2*2*3*3));
46
47 // Innermost 'if'
48 // a > b.
49 Expect.equals(60, lcm(2*2*3*5, 2*3));
50 // a == b.
51 Expect.equals(24, lcm(2*3, 2*2*2*3));
52 // a < b.
53 Expect.equals(84, lcm(2*3, 2*2*3*7));
54
55 // do while loop executions.
56 // Executed 1 time.
57 Expect.equals(24, lcm(2*3, 2*2*2*3));
58 // Executed >1 times.
59 Expect.equals(180, lcm(2*3*3, 2*2*3*5));
60
61 // Medium int (mint) arguments.
62 Expect.equals(pow(2, 62)*3, lcm(pow(2, 61)*3, pow(2,62)));
63 // 9079837958533 is the first prime after 2**48 / 31.
64 Expect.equals(31*37*9079837958533,
65 lcm(31*9079837958533, 37*9079837958533));
66 }
67
68 main() {
69 testLcm();
70 }
OLDNEW
« no previous file with comments | « pkg/math/test/invert_test.dart ('k') | pkg/math/test/powmod_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698