blob: a65f9954352e18eb3e4eb8ed81f26cfd441f08cb [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// 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: --expose-natives-as natives
6// Test the MaxSimple and MinSimple internal methods in runtime.js
7
8var MaxSimple = natives.ImportNow("MaxSimple");
9var MinSimple = natives.ImportNow("MinSimple");
10
11function checkEvaluations(target) {
12 var evaluations = 0;
13 var observedNumber = {
14 valueOf: function() {
15 evaluations++;
16 return 0;
17 }
18 };
19 target(observedNumber, observedNumber);
20 return evaluations;
21}
22
23assertEquals(1, MaxSimple(-1, 1));
24assertEquals(2, checkEvaluations(MaxSimple));
25
26assertEquals(-1, MinSimple(-1, 1));
27assertEquals(2, checkEvaluations(MinSimple));