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

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

Issue 81623003: Use range information to omit checks in TRUNCDIV/MOD operations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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 | « tests/language/modulo_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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 // Dart test optimization of modulo operator on Smi.
5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr
6
7 import "package:expect/expect.dart";
8
9
10 main() {
11 for (int i = -30; i < 30; i++) {
12 Expect.equals(i % 9, foo(i, 9));
13 // Zero test is done outside the loop.
14 if (i < 0) {
15 Expect.equals(i ~/ -i, foo2(i));
16 } else if (i > 0) {
17 Expect.equals(i ~/ i, foo2(i));
18 }
19 }
20 Expect.throws(() => foo(12, 0), (e) => e is IntegerDivisionByZeroException);
21 Expect.throws(() => foo2(0), (e) => e is IntegerDivisionByZeroException);
22 }
23
24 foo(i, x) => i % x;
25
26 foo2(i) {
27 // Make sure x has a range computed.
28 var x = 0;
29 if (i < 0) {
30 x = -i;
31 } else {
32 x = i;
33 }
34 return i ~/ x;
35 }
OLDNEW
« no previous file with comments | « tests/language/modulo_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698