-
-
Notifications
You must be signed in to change notification settings - Fork 230
/
expressions.yaml
92 lines (84 loc) · 2.05 KB
/
expressions.yaml
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
---
name: simple expression
code: |
var x = args[0] > 0 && args[0] < 5;
output = x;
tests:
- name: covers line and one branch
args: [-1]
out: false
lines: {'1': 1, '2': 1}
branches: {'0': [1, 0]}
statements: {'0': 1, '1': 1}
- name: covers line, both branches, returns false
args: [10]
out: false
lines: {'1': 1, '2': 1}
branches: {'0': [1, 1]}
statements: {'0': 1, '1': 1}
- name: covers line, both branches, returns true
args: [3]
out: true
lines: {'1': 1, '2': 1}
branches: {'0': [1, 1]}
statements: {'0': 1, '1': 1}
---
name: complex expression
code: |
var x = args[0] > 0 && (args[0] < 5 || args[0] > 10);
output = x;
tests:
- name: covers line and one branch
args: [-1]
out: false
lines: {'1': 1, '2': 1}
branches: {'0': [1, 0, 0]}
statements: {'0': 1, '1': 1}
- name: covers line, both branches, returns false
args: [9]
out: false
lines: {'1': 1, '2': 1}
branches: {'0': [1, 1, 1]}
statements: {'0': 1, '1': 1}
- name: covers line, both branches, returns true
args: [3]
out: true
lines: {'1': 1, '2': 1}
branches: {'0': [1, 1, 0]}
statements: {'0': 1, '1': 1}
---
name: array expression with empty positions
code: |
var x = [args[0], , args[1], ];
output = x.indexOf(args[1]) === x.length - 1 && x[0] !== x[1];
tests:
- name: covers correctly without error
args: [1,5]
out: true
lines: {'1': 1, '2': 1}
branches: { '0': [1, 1] }
statements: {'0': 1, '1': 1}
---
name: or with object expression (bug track)
code: |
var x = args[0] ? { foo: 1 } : { foo: 2 };
output = x.foo;
tests:
- name: covers all branches correctly
args: [ false ]
out: 2
lines: {'1': 1, '2': 1}
branches: { '0': [0, 1] }
statements: {'0': 1, '1': 1}
---
name: or with object expression (part 2)
code: |
var x = args[0] || { foo: 2 };
output = x.foo;
tests:
- name: covers all branches correctly
args: [ false ]
out: 2
lines: {'1': 1, '2': 1}
branches: { '0': [1, 1] }
statements: {'0': 1, '1': 1}