Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Math/min/S15.8.2.12_A2.js

raw
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 info: If any value is NaN, the result of Math.min is NaN
6 es5id: 15.8.2.12_A2
7 description: >
8 The script tests Math.min giving 1, 2 and 3 arguments to the
9 function where at least one of the arguments is NaN
10 ---*/
11
12 // CHECK#1
13 assert.sameValue(Math.min(NaN), NaN, "NaN");
14
15 // CHECK#2
16 var vals = new Array();
17 vals[0] = -Infinity;
18 vals[1] = -0.000000000000001;
19 vals[2] = -0;
20 vals[3] = +0
21 vals[4] = 0.000000000000001;
22 vals[5] = +Infinity;
23 vals[6] = NaN;
24 var valnum = 7;
25
26 var args = new Array();
27 for (var i = 0; i <= 1; i++)
28 {
29 args[i] = NaN;
30 for (var j = 0; j < valnum; j++)
31 {
32 args[1 - i] = vals[j];
33 assert.sameValue(
34 Math.min(args[0], args[1]),
35 NaN,
36 "min(" + args[0] + ", " + args[1] + ")"
37 );
38 }
39 }
40
41 // CHECK #3
42 var k = 1;
43 var l = 2;
44 for (var i = 0; i <= 2; i++)
45 {
46 args[i] = NaN;
47 if (i === 1)
48 {
49 k = 0;
50 } else if (i === 2)
51 {
52 l = 1;
53 }
54 for (var j = 0; j < valnum; j++)
55 {
56 for (var jj = 0; jj < valnum; jj++)
57 {
58 args[k] = vals[j];
59 args[l] = vals[jj];
60 assert.sameValue(
61 Math.min(args[0], args[1], args[2]),
62 NaN,
63 "min(" + args[0] + ", " + args[1] + ", " + args[2] + ")"
64 );
65 }
66 }
67 }