|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 |
|
7 /** |
|
8 * File Name: 11.4.7-02.js |
|
9 * Reference: https://bugzilla.mozilla.org/show_bug.cgi?id=432881 |
|
10 * Description: ecma 11.4.7 |
|
11 */ |
|
12 |
|
13 var SECTION = "11.4.7"; |
|
14 var VERSION = "ECMA"; |
|
15 var TITLE = "Unary - Operator"; |
|
16 var BUGNUMBER = "432881"; |
|
17 |
|
18 startTest(); |
|
19 |
|
20 test_negation(0, -0.0); |
|
21 test_negation(-0.0, 0); |
|
22 test_negation(1, -1); |
|
23 test_negation(1.0/0.0, -1.0/0.0); |
|
24 test_negation(-1.0/0.0, 1.0/0.0); |
|
25 |
|
26 //1073741824 == (1 << 30) |
|
27 test_negation(1073741824, -1073741824); |
|
28 test_negation(-1073741824, 1073741824); |
|
29 |
|
30 //1073741824 == (1 << 30) - 1 |
|
31 test_negation(1073741823, -1073741823); |
|
32 test_negation(-1073741823, 1073741823); |
|
33 |
|
34 //1073741824 == (1 << 30) |
|
35 test_negation(1073741824, -1073741824); |
|
36 test_negation(-1073741824, 1073741824); |
|
37 |
|
38 //1073741824 == (1 << 30) - 1 |
|
39 test_negation(1073741823, -1073741823); |
|
40 test_negation(-1073741823, 1073741823); |
|
41 |
|
42 //2147483648 == (1 << 31) |
|
43 test_negation(2147483648, -2147483648); |
|
44 test_negation(-2147483648, 2147483648); |
|
45 |
|
46 //2147483648 == (1 << 31) - 1 |
|
47 test_negation(2147483647, -2147483647); |
|
48 test_negation(-2147483647, 2147483647); |
|
49 |
|
50 function test_negation(value, expected) |
|
51 { |
|
52 var actual = -value; |
|
53 reportCompare(expected, actual, '-(' + value + ') == ' + expected); |
|
54 } |