MCPcopy
hub / github.com/tdewolff/minify / TestJS

Function TestJS

js/js_test.go:16–883  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestJS(t *testing.T) {
17 jsTests := []struct {
18 js string
19 expected string
20 }{
21 {`#!shebang`, `#!shebang`},
22 {`/*comment*/a`, `a`},
23 {`/*!comment*/a`, `/*!comment*/a`},
24 {"//!comment1\n\n//!comment2\na", "//!comment1\n//!comment2\na"},
25 {`debugger`, `debugger`},
26 {`"use strict"`, `"use strict"`},
27 {`1.0`, `1`},
28 {`1_2.0_3`, `12.03`},
29 {`1000`, `1e3`},
30 {`1e10`, `1e10`},
31 {`1e-10`, `1e-10`},
32 {`5_000`, `5e3`},
33 {`5_000n`, `5000n`},
34 {`0b1001`, `9`},
35 {`0b10_01`, `9`},
36 {`0b10_01n`, `9n`},
37 {`0o11`, `9`},
38 {`0o11n`, `9n`},
39 {`0x0D`, `13`},
40 {`0x0d`, `13`},
41 {`0x0dn`, `13n`},
42 {`0x53DCAA254718n`, `0x53DCAA254718n`},
43 //{`123456787654321`, `0x704885f926b1`},
44 //{`4294967295`, `0xFFFFFFFF`}, // better GZIP
45 {`+ +x`, `+ +x`},
46 {`- -x`, `- -x`},
47 {`- +x`, `-+x`},
48 {`+ ++x`, `+ ++x`},
49 {`- --x`, `- --x`},
50 {`- ++x`, `-++x`},
51 {`a + ++b`, `a+ ++b`},
52 {`a - --b`, `a- --b`},
53 {`a++ +b`, `a+++b`},
54 {`a-- -b`, `a---b`},
55 {`a - ++b`, `a-++b`},
56 {`a-- > b`, `a-- >b`},
57 {`(a--) > b`, `a-- >b`},
58 {`a-- < b`, `a--<b`},
59 {`a < !--b`, `a<! --b`},
60 {`a > !--b`, `a>!--b`},
61 {`!--b`, `!--b`},
62 {`/a/ + b`, `/a/+b`},
63 {`/a/ instanceof b`, `/a/ instanceof b`},
64 {`[a] instanceof b`, `[a]instanceof b`},
65 {`let a = 5;a`, `let a=5;a`},
66 {`let a = 5,b;a,b`, `let a=5,b;a,b`},
67 {`let a,b = 5;a,b`, `let a,b=5;a,b`},
68 {`function a(){}`, `function a(){}`},
69 {`function a(b){b}`, `function a(b){b}`},
70 {`function a(b, c, ...d){}`, `function a(b,c,...d){}`},
71 {`function * a(){}`, `function*a(){}`},
72 {`function a(){}; break`, `function a(){}break`},
73 {`x = function (){}`, `x=function(){}`},

Callers

nothing calls this directly

Calls 4

MinifyMethod · 0.95
RunMethod · 0.80
MinifyMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…