summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Boolean/S9.2_A6_T1.js
blob: bfacbb758a706ed6cd3496151772c4870038dc6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2009 the Sputnik authors.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: Result of boolean conversion from object is true
esid: sec-toboolean
description: Different objects convert to Boolean by explicit transformation
---*/

assert.sameValue(Boolean(new Object()), true, 'Boolean(new Object()) must return true');
assert.sameValue(Boolean(new String("")), true, 'Boolean(new String("")) must return true');
assert.sameValue(Boolean(new String()), true, 'Boolean(new String()) must return true');
assert.sameValue(Boolean(new Boolean(true)), true, 'Boolean(new Boolean(true)) must return true');
assert.sameValue(Boolean(new Boolean(false)), true, 'Boolean(new Boolean(false)) must return true');
assert.sameValue(Boolean(new Boolean()), true, 'Boolean(new Boolean()) must return true');
assert.sameValue(Boolean(new Array()), true, 'Boolean(new Array()) must return true');
assert.sameValue(Boolean(new Number()), true, 'Boolean(new Number()) must return true');
assert.sameValue(Boolean(new Number(-0)), true, 'Boolean(new Number(-0)) must return true');
assert.sameValue(Boolean(new Number(0)), true, 'Boolean(new Number(0)) must return true');
assert.sameValue(Boolean(new Number()), true, 'Boolean(new Number()) must return true');
assert.sameValue(Boolean(new Number(Number.NaN)), true, 'Boolean(new Number(Number.NaN)) must return true');
assert.sameValue(Boolean(new Number(-1)), true, 'Boolean(new Number(-1)) must return true');
assert.sameValue(Boolean(new Number(1)), true, 'Boolean(new Number(1)) must return true');

assert.sameValue(
  Boolean(new Number(Number.POSITIVE_INFINITY)),
  true,
  'Boolean(new Number(Number.POSITIVE_INFINITY)) must return true'
);

assert.sameValue(
  Boolean(new Number(Number.NEGATIVE_INFINITY)),
  true,
  'Boolean(new Number(Number.NEGATIVE_INFINITY)) must return true'
);

assert.sameValue(Boolean(new Function()), true, 'Boolean(new Function()) must return true');
assert.sameValue(Boolean(new Date()), true, 'Boolean(new Date()) must return true');
assert.sameValue(Boolean(new Date(0)), true, 'Boolean(new Date(0)) must return true');

reportCompare(0, 0);