summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_6/String/raw.js
blob: 1472185af27a8c9127790e374e7677f0b9e06019 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var BUGNUMBER = 1039774;
var summary = 'String.raw';

print(BUGNUMBER + ": " + summary);

assertThrowsInstanceOf(function() { String.raw(); }, TypeError);

assertEq(String.raw.length, 1);

var cooked = [];
assertThrowsInstanceOf(function() { String.raw(cooked); }, TypeError);

cooked.raw = {};
assertEq(String.raw(cooked), "");

cooked.raw = {lengt: 0};
assertEq(String.raw(cooked), "");

cooked.raw = {length: 0};
assertEq(String.raw(cooked), "");

cooked.raw = {length: -1};
assertEq(String.raw(cooked), "");

cooked.raw = [];
assertEq(String.raw(cooked), "");

cooked.raw = ["a"];
assertEq(String.raw(cooked), "a");

cooked.raw = ["a", "b"];
assertEq(String.raw(cooked, "x"), "axb");

cooked.raw = ["a", "b"];
assertEq(String.raw(cooked, "x", "y"), "axb");

cooked.raw = ["a", "b", "c"];
assertEq(String.raw(cooked, "x"), "axbc");

cooked.raw = ["a", "b", "c"];
assertEq(String.raw(cooked, "x", "y"), "axbyc");

cooked.raw = ["\n", "\r\n", "\r"];
assertEq(String.raw(cooked, "x", "y"), "\nx\r\ny\r");

cooked.raw = ["\n", "\r\n", "\r"];
assertEq(String.raw(cooked, "\r\r", "\n"), "\n\r\r\r\n\n\r");

cooked.raw = {length: 2, '0':"a", '1':"b", '2':"c"};
assertEq(String.raw(cooked, "x", "y"), "axb");

cooked.raw = {length: 4, '0':"a", '1':"b", '2':"c"};
assertEq(String.raw(cooked, "x", "y"), "axbycundefined");

reportCompare(0, 0, "ok");