File: commaOperatorLeftSideUnused.js

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (103 lines) | stat: -rw-r--r-- 1,946 bytes parent folder | download | duplicates (6)
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
91
92
93
94
95
96
97
98
99
100
101
102
103
//// [commaOperatorLeftSideUnused.ts]
var xx: any;
var yy: any;

function fn() {
  let arr: any[] = [];
  switch(arr.length) {
    // Should error
    case 0, 1:
      return 'zero or one';
    default:
      return 'more than one';
  }
}

// Should error
let x = Math.pow((3, 5), 2);

// Should error
let a = [(3 + 4), ((1 + 1, 8) * 4)];

// Error cases
xx = (1, 2);
xx = ('', xx);
xx = (/323/, 5);
xx = (`wat`, 'ok'),
xx = (true, false);
xx = (false, true);
xx = (null, xx);
xx = (undefined, 10);
xx = (() => {}, 'no');
xx = (function() { }, 100);
xx = ({}, {});
xx = (typeof xx, 'unused');
xx = ([1, 2, x++], xx);
xx = (xx!, xx);
xx = (xx ? 3 : 4, 10);
xx = (3 + 4, 10);
xx = (!xx, 10);
xx = (~xx, 10);
xx = (-xx, 10);
xx = (+xx, 10);

// OK cases
xx = (xx ? x++ : 4, 10);
xx = (--xx, 3);
xx = (xx = 3, 1);
xx = ((xx = 3), 5);
xx = (xx+= 4, xx);
xx = ((xx+= 4), xx);
xx = (Math.pow(3, 2), 4);
xx = (void xx, 10);
xx = (xx as any, 100);


//// [commaOperatorLeftSideUnused.js]
var xx;
var yy;
function fn() {
    var arr = [];
    switch (arr.length) {
        // Should error
        case 0, 1:
            return 'zero or one';
        default:
            return 'more than one';
    }
}
// Should error
var x = Math.pow((3, 5), 2);
// Should error
var a = [(3 + 4), ((1 + 1, 8) * 4)];
// Error cases
xx = (1, 2);
xx = ('', xx);
xx = (/323/, 5);
xx = ("wat", 'ok'),
    xx = (true, false);
xx = (false, true);
xx = (null, xx);
xx = (undefined, 10);
xx = (function () { }, 'no');
xx = (function () { }, 100);
xx = ({}, {});
xx = (typeof xx, 'unused');
xx = ([1, 2, x++], xx);
xx = (xx, xx);
xx = (xx ? 3 : 4, 10);
xx = (3 + 4, 10);
xx = (!xx, 10);
xx = (~xx, 10);
xx = (-xx, 10);
xx = (+xx, 10);
// OK cases
xx = (xx ? x++ : 4, 10);
xx = (--xx, 3);
xx = (xx = 3, 1);
xx = ((xx = 3), 5);
xx = (xx += 4, xx);
xx = ((xx += 4), xx);
xx = (Math.pow(3, 2), 4);
xx = (void xx, 10);
xx = (xx, 100);