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

Side by Side Diff: tests/language/truncdiv_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // Dart test optimization of modulo operator on Smi. 4 // Dart test optimization of modulo operator on Smi.
5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr --no-background-co mpilation 5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr --no-background-co mpilation
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 8
9
10 main() { 9 main() {
11 for (int i = -30; i < 30; i++) { 10 for (int i = -30; i < 30; i++) {
12 Expect.equals(i % 9, foo(i, 9)); 11 Expect.equals(i % 9, foo(i, 9));
13 // Zero test is done outside the loop. 12 // Zero test is done outside the loop.
14 if (i < 0) { 13 if (i < 0) {
15 Expect.equals(i ~/ -i, foo2(i)); 14 Expect.equals(i ~/ -i, foo2(i));
16 } else if (i > 0) { 15 } else if (i > 0) {
17 Expect.equals(i ~/ i, foo2(i)); 16 Expect.equals(i ~/ i, foo2(i));
18 } 17 }
19 } 18 }
20 Expect.throws(() => foo(12, 0), (e) => e is IntegerDivisionByZeroException); 19 Expect.throws(() => foo(12, 0), (e) => e is IntegerDivisionByZeroException);
21 Expect.throws(() => foo2(0), (e) => e is IntegerDivisionByZeroException); 20 Expect.throws(() => foo2(0), (e) => e is IntegerDivisionByZeroException);
22 } 21 }
23 22
24 foo(i, x) => i % x; 23 foo(i, x) => i % x;
25 24
26 foo2(i) { 25 foo2(i) {
27 // Make sure x has a range computed. 26 // Make sure x has a range computed.
28 var x = 0; 27 var x = 0;
29 if (i < 0) { 28 if (i < 0) {
30 x = -i; 29 x = -i;
31 } else { 30 } else {
32 x = i; 31 x = i;
33 } 32 }
34 return i ~/ x; 33 return i ~/ x;
35 } 34 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698