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

Side by Side Diff: test/mjsunit/math-min-max.js

Issue 21173004: Version 3.20.11.1 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 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 | « test/mjsunit/generated-transition-stub.js ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 function crankshaft_test_2() { 171 function crankshaft_test_2() {
172 var v9 = {}; 172 var v9 = {};
173 v9.valueOf = function() { return 6; } 173 v9.valueOf = function() { return 6; }
174 // Deopt expected due to non-heapnumber objects. 174 // Deopt expected due to non-heapnumber objects.
175 assertEquals(6, Math.min(v9, 12)); 175 assertEquals(6, Math.min(v9, 12));
176 } 176 }
177 177
178 run(crankshaft_test_2); 178 run(crankshaft_test_2);
179 179
180 var o = { a: 1, b: 2 };
181
182 // Test smi-based Math.min.
183 function f(o) {
184 return Math.min(o.a, o.b);
185 }
186
187 assertEquals(1, f(o));
188 assertEquals(1, f(o));
189 %OptimizeFunctionOnNextCall(f);
190 assertEquals(1, f(o));
191 o.a = 5;
192 o.b = 4;
193 assertEquals(4, f(o));
194
195 // Test overriding Math.min and Math.max 180 // Test overriding Math.min and Math.max
196 Math.min = function(a, b) { return a + b; } 181 Math.min = function(a, b) { return a + b; }
197 Math.max = function(a, b) { return a - b; } 182 Math.max = function(a, b) { return a - b; }
198 183
199 function crankshaft_test_3() { 184 function crankshaft_test_3() {
200 assertEquals(8, Math.min(3, 5)); 185 assertEquals(8, Math.min(3, 5));
201 assertEquals(3, Math.max(5, 2)); 186 assertEquals(3, Math.max(5, 2));
202 } 187 }
203 188
204 run(crankshaft_test_3); 189 run(crankshaft_test_3);
OLDNEW
« no previous file with comments | « test/mjsunit/generated-transition-stub.js ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698