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

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

Issue 140233002: Fix issue 16103 (VM crash): incorrect merging of sin/cos. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 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 | « runtime/vm/flow_graph_optimizer.cc ('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 // Dart test program to test arithmetic operations. 4 // Dart test program to test arithmetic operations.
5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr 5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr
6 6
7 library arithmetic_test; 7 library arithmetic_test;
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 import 'dart:math'; 9 import 'dart:math';
10 10
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 static int divMod(a, b) => a ~/ b + a % b; 428 static int divMod(a, b) => a ~/ b + a % b;
429 429
430 static void testSmiDivModDeopt() { 430 static void testSmiDivModDeopt() {
431 var a = -0x40000000; 431 var a = -0x40000000;
432 var b = -1; 432 var b = -1;
433 for (var i = 0; i < 10; i++) Expect.equals(0x40000000, divMod(a, b)); 433 for (var i = 0; i < 10; i++) Expect.equals(0x40000000, divMod(a, b));
434 } 434 }
435 435
436 static double sinCosSub(double a) => sin(a) - cos(a); 436 static double sinCosSub(double a) => sin(a) - cos(a);
437 437
438 static double sinCosAddCos(double a) => sin(a) * cos(a) + cos(a);
439
438 static void testSinCos() { 440 static void testSinCos() {
439 var e = sin(1.234) - cos(1.234); 441 var e = sin(1.234) - cos(1.234);
442 var f = sin(1.234) * cos(1.234) + cos(1.234);
443
440 for (var i = 0; i < 20; i++) { 444 for (var i = 0; i < 20; i++) {
441 Expect.approxEquals(e, sinCosSub(1.234)); 445 Expect.approxEquals(e, sinCosSub(1.234));
446 Expect.approxEquals(f, sinCosAddCos(1.234));
442 } 447 }
443 Expect.approxEquals(1.0, sinCosSub(3.14159265)); 448 Expect.approxEquals(1.0, sinCosSub(3.14159265));
444 Expect.approxEquals(1.0, sinCosSub(3.14159265 / 2.0)); 449 Expect.approxEquals(1.0, sinCosSub(3.14159265 / 2.0));
445 } 450 }
446 451
447 static mySqrt(var x) => sqrt(x); 452 static mySqrt(var x) => sqrt(x);
448 453
449 static testSqrtDeopt() { 454 static testSqrtDeopt() {
450 for (var i = 0; i < 10; i++) mySqrt(4.0); 455 for (var i = 0; i < 10; i++) mySqrt(4.0);
451 Expect.equals(2.0, mySqrt(4.0)); 456 Expect.equals(2.0, mySqrt(4.0));
(...skipping 20 matching lines...) Expand all
472 testSqrtDeopt(); 477 testSqrtDeopt();
473 testDoubleEquality(); 478 testDoubleEquality();
474 testSinCos(); 479 testSinCos();
475 } 480 }
476 } 481 }
477 } 482 }
478 483
479 main() { 484 main() {
480 ArithmeticTest.testMain(); 485 ArithmeticTest.testMain();
481 } 486 }
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698