2011-09-07 08:35:18 +02:00
|
|
|
// Copyright 2009 the Sputnik authors. All rights reserved.
|
|
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
|
2014-07-22 01:09:02 +02:00
|
|
|
/*---
|
|
|
|
info: Result of boolean conversion from object is true
|
2017-07-27 18:17:54 +02:00
|
|
|
esid: sec-toboolean
|
2014-07-22 01:09:02 +02:00
|
|
|
description: Different objects convert to Boolean by explicit transformation
|
|
|
|
---*/
|
2011-09-07 08:35:18 +02:00
|
|
|
|
|
|
|
// CHECK#1
|
|
|
|
if (Boolean(new Object()) !== true) {
|
2021-07-21 20:55:36 +02:00
|
|
|
throw new Test262Error('#1: Boolean(new Object()) === true. Actual: ' + (Boolean(new Object())));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#2
|
|
|
|
if (Boolean(new String("")) !== true) {
|
2021-07-21 20:55:36 +02:00
|
|
|
throw new Test262Error('#2: Boolean(new String("")) === true. Actual: ' + (Boolean(new String(""))));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#3
|
|
|
|
if (Boolean(new String()) !== true) {
|
2021-07-21 20:55:36 +02:00
|
|
|
throw new Test262Error('#3: Boolean(new String()) === true. Actual: ' + (Boolean(new String())));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#4
|
|
|
|
if (Boolean(new Boolean(true)) !== true) {
|
2021-07-21 20:55:36 +02:00
|
|
|
throw new Test262Error('#4: Boolean(new Boolean(true)) === true. Actual: ' + (Boolean(new Boolean(true))));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#5
|
|
|
|
if (Boolean(new Boolean(false)) !== true) {
|
2021-07-21 20:55:36 +02:00
|
|
|
throw new Test262Error('#5: Boolean(new Boolean(false)) === true. Actual: ' + (Boolean(new Boolean(false))));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#6
|
|
|
|
if (Boolean(new Boolean()) !== true) {
|
2021-07-21 20:55:36 +02:00
|
|
|
throw new Test262Error('#6: Boolean(new Boolean()) === true. Actual: ' + (Boolean(new Boolean())));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#7
|
|
|
|
if (Boolean(new Array()) !== true) {
|
2021-07-21 20:55:36 +02:00
|
|
|
throw new Test262Error('#7: Boolean(new Array()) === true. Actual: ' + (Boolean(new Array())));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#8
|
|
|
|
if (Boolean(new Number()) !== true) {
|
2021-07-21 20:55:36 +02:00
|
|
|
throw new Test262Error('#8: Boolean(new Number()) === true. Actual: ' + (Boolean(new Number())));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#9
|
|
|
|
if (Boolean(new Number(-0)) !== true) {
|
2021-07-21 20:55:36 +02:00
|
|
|
throw new Test262Error('#9: Boolean(new Number(-0)) === true. Actual: ' + (Boolean(new Number(-0))));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#10
|
|
|
|
if (Boolean(new Number(0)) !== true) {
|
2021-07-21 20:55:36 +02:00
|
|
|
throw new Test262Error('#10: Boolean(new Number(0)) === true. Actual: ' + (Boolean(new Number(0))));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#11
|
|
|
|
if (Boolean(new Number()) !== true) {
|
2021-07-21 20:55:36 +02:00
|
|
|
throw new Test262Error('#11: Boolean(new Number()) === true. Actual: ' + (Boolean(new Number())));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#12
|
|
|
|
if (Boolean(new Number(Number.NaN)) !== true) {
|
2021-07-21 20:55:36 +02:00
|
|
|
throw new Test262Error('#12: Boolean(new Number(Number.NaN)) === true. Actual: ' + (Boolean(new Number(Number.NaN))));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#13
|
|
|
|
if (Boolean(new Number(-1)) !== true) {
|
2021-07-21 20:55:36 +02:00
|
|
|
throw new Test262Error('#13: Boolean(new Number(-1)) === true. Actual: ' + (Boolean(new Number(-1))));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#14
|
|
|
|
if (Boolean(new Number(1)) !== true) {
|
2021-07-21 20:55:36 +02:00
|
|
|
throw new Test262Error('#14: Boolean(new Number(1)) === true. Actual: ' + (Boolean(new Number(1))));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#15
|
|
|
|
if (Boolean(new Number(Number.POSITIVE_INFINITY)) !== true) {
|
2021-07-21 20:55:36 +02:00
|
|
|
throw new Test262Error('#15: Boolean(new Number(Number.POSITIVE_INFINITY)) === true. Actual: ' + (Boolean(new Number(Number.POSITIVE_INFINITY))));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#16
|
|
|
|
if (Boolean(new Number(Number.NEGATIVE_INFINITY)) !== true) {
|
2021-07-21 20:55:36 +02:00
|
|
|
throw new Test262Error('#16: Boolean(new Number(Number.NEGATIVE_INFINITY)) === true. Actual: ' + (Boolean(new Number(Number.NEGATIVE_INFINITY))));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#17
|
|
|
|
if (Boolean(new Function()) !== true) {
|
2021-07-21 20:55:36 +02:00
|
|
|
throw new Test262Error('#17: Boolean(new Function()) === true. Actual: ' + (Boolean(new Function())));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#18
|
|
|
|
if (Boolean(new Date()) !== true) {
|
2021-07-21 20:55:36 +02:00
|
|
|
throw new Test262Error('#18: Boolean(new Date()) === true. Actual: ' + (Boolean(new Date())));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK#19
|
|
|
|
if (Boolean(new Date(0)) !== true) {
|
2021-07-21 20:55:36 +02:00
|
|
|
throw new Test262Error('#19: Boolean(new Date(0)) === true. Actual: ' + (Boolean(new Date(0))));
|
2011-09-07 08:35:18 +02:00
|
|
|
}
|