| 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: | |
| 6 |
If Type(Primitive(x)) is not String and Type(Primitive(y)) is not String, |
| 7 |
then operator x + y returns ToNumber(x) + ToNumber(y) |
| 8 |
es5id: 11.6.1_A3.1_T2.1 |
| 9 |
description: > |
| 10 |
Type(Primitive(x)) is different from Type(Primitive(y)) and both |
| 11 |
types vary between Number (primitive or object) or Boolean |
| 12 |
(primitive and object) |
| 13 |
---*/ |
| 14 |
|
| 15 |
//CHECK#1 |
| 16 |
if (true + 1 !== 2) { |
| 17 |
$ERROR('#1: true + 1 === 2. Actual: ' + (true + 1)); |
| 18 |
} |
| 19 |
|
| 20 |
//CHECK#2 |
| 21 |
if (1 + true !== 2) { |
| 22 |
$ERROR('#2: 1 + true === 2. Actual: ' + (1 + true)); |
| 23 |
} |
| 24 |
|
| 25 |
//CHECK#3 |
| 26 |
if (new Boolean(true) + 1 !== 2) { |
| 27 |
$ERROR('#3: new Boolean(true) + 1 === 2. Actual: ' + (new Boolean(true) + 1)); |
| 28 |
} |
| 29 |
|
| 30 |
//CHECK#4 |
| 31 |
if (1 + new Boolean(true) !== 2) { |
| 32 |
$ERROR('#4: 1 + new Boolean(true) === 2. Actual: ' + (1 + new Boolean(true))); |
| 33 |
} |
| 34 |
|
| 35 |
//CHECK#5 |
| 36 |
if (true + new Number(1) !== 2) { |
| 37 |
$ERROR('#5: true + new Number(1) === 2. Actual: ' + (true + new Number(1))); |
| 38 |
} |
| 39 |
|
| 40 |
//CHECK#6 |
| 41 |
if (new Number(1) + true !== 2) { |
| 42 |
$ERROR('#6: new Number(1) + true === 2. Actual: ' + (new Number(1) + true)); |
| 43 |
} |
| 44 |
|
| 45 |
//CHECK#7 |
| 46 |
if (new Boolean(true) + new Number(1) !== 2) { |
| 47 |
$ERROR('#7: new Boolean(true) + new Number(1) === 2. Actual: ' + (new Boolean(true) + new Number(1))); |
| 48 |
} |
| 49 |
|
| 50 |
//CHECK#8 |
| 51 |
if (new Number(1) + new Boolean(true) !== 2) { |
| 52 |
$ERROR('#8: new Number(1) + new Boolean(true) === 2. Actual: ' + (new Number(1) + new Boolean(true))); |
| 53 |
} |