aboutsummaryrefslogtreecommitdiff
path: root/test/compress/issue-269.js
blob: a29e7541177e89736d389842e8ffb365b2857ad7 (about) (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
issue_269_1: {
	options = {unsafe: true};
	input: {
		f(
			String(x),
			Number(x),
			Boolean(x),

			String(),
			Number(),
			Boolean()
		);
	}
	expect: {
		f(
			x + '', +x, !!x,
			'', 0, false
		);
	}
}

issue_269_dangers: {
	options = {unsafe: true};
	input: {
		f(
			String(x, x),
			Number(x, x),
			Boolean(x, x)
		);
	}
	expect: {
		f(String(x, x), Number(x, x), Boolean(x, x));
	}
}

issue_269_in_scope: {
	options = {unsafe: true};
	input: {
		var String, Number, Boolean;
		f(
			String(x),
			Number(x, x),
			Boolean(x)
		);
	}
	expect: {
		var String, Number, Boolean;
		f(String(x), Number(x, x), Boolean(x));
	}
}

strings_concat: {
	options = {unsafe: true};
	input: {
		f(
			String(x + 'str'),
			String('str' + x)
		);
	}
	expect: {
		f(
			x + 'str',
			'str' + x
		);
	}
}

regexp: {
	options = {
		evaluate: true,
		unsafe: true,
	}
	input: {
		RegExp("foo");
		RegExp("bar", "ig");
		RegExp(foo);
		RegExp("bar", ig);
		RegExp("should", "fail");
	}
	expect: {
		/foo/;
		/bar/ig;
		RegExp(foo);
		RegExp("bar", ig);
		RegExp("should", "fail");
	}
	expect_warnings: [
		'WARN: Error converting RegExp("should","fail") [test/compress/issue-269.js:78,2]',
	]
}