OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Flags: --allow-natives-syntax | |
6 // Test the MaxSimple and MinSimple internal methods in runtime.js | |
7 | |
8 function MaxSimple(a, b) { | |
9 return a > b ? a : b; | |
10 } | |
11 | |
12 function MinSimple(a, b) { | |
13 return a > b ? b : a; | |
14 } | |
15 | |
16 %SetForceInlineFlag(MaxSimple); | |
17 %SetForceInlineFlag(MinSimple); | |
18 | |
19 function checkEvaluations(target) { | |
20 var evaluations = 0; | |
21 var observedNumber = { | |
22 valueOf: function() { | |
23 evaluations++; | |
24 return 0; | |
25 } | |
26 }; | |
27 target(observedNumber, observedNumber); | |
28 return evaluations; | |
29 } | |
30 | |
31 assertEquals(1, MaxSimple(-1, 1)); | |
32 assertEquals(2, checkEvaluations(MaxSimple)); | |
33 | |
34 | |
35 assertEquals(-1, MinSimple(-1, 1)); | |
36 assertEquals(2, checkEvaluations(MaxSimple)); | |
Jakob Kummerow
2015/10/15 14:18:48
Clearly you mean MinSimple here.
skomski
2015/10/15 15:17:58
Done.
| |
OLD | NEW |