|
48 | 48 | "category": "operator", |
49 | 49 | "description": "should wrap operators with the same precedence in parenthesis when needed", |
50 | 50 | "tests": [ |
51 | | - { "input": ["multiply", 2, 3, 4], "output": "2 * 3 * 4" }, |
52 | | - { "input": ["multiply", ["multiply", 2, 3], 4], "output": "(2 * 3) * 4" }, |
| 51 | + { "input": ["pow", ["pow", 2, 3], 4], "output": "(2 ^ 3) ^ 4" }, |
| 52 | + { "input": ["pow", 2, ["pow", 3, 4]], "output": "2 ^ (3 ^ 4)" }, |
| 53 | + { "input": ["multiply", ["multiply", 2, 3], 4], "output": "2 * 3 * 4" }, |
53 | 54 | { "input": ["multiply", 2, ["multiply", 3, 4]], "output": "2 * (3 * 4)" }, |
54 | | - { "input": ["divide", 2, 3, 4], "output": "2 / 3 / 4" }, |
55 | | - { "input": ["divide", ["divide", 2, 3], 4], "output": "(2 / 3) / 4" }, |
| 55 | + { "input": ["divide", ["divide", 2, 3], 4], "output": "2 / 3 / 4" }, |
56 | 56 | { "input": ["divide", 2, ["divide", 3, 4]], "output": "2 / (3 / 4)" }, |
57 | 57 | { "input": ["divide", ["multiply", 2, 3], 4], "output": "2 * 3 / 4" }, |
58 | 58 | { "input": ["divide", 2, ["multiply", 3, 4]], "output": "2 / (3 * 4)" }, |
|
62 | 62 | "output": "2 / (3 * 4) / (5 * 6)" |
63 | 63 | }, |
64 | 64 | { "input": ["multiply", ["divide", 2, 3], 4], "output": "2 / 3 * 4" }, |
65 | | - { "input": ["mod", 2, 3, 4], "output": "2 % 3 % 4" }, |
66 | | - { "input": ["mod", ["mod", 2, 3], 4], "output": "(2 % 3) % 4" }, |
| 65 | + { "input": ["mod", ["mod", 2, 3], 4], "output": "2 % 3 % 4" }, |
67 | 66 | { "input": ["mod", 2, ["mod", 3, 4]], "output": "2 % (3 % 4)" }, |
68 | 67 | { "input": ["mod", ["multiply", 2, 3], 4], "output": "2 * 3 % 4" }, |
69 | 68 | { "input": ["multiply", ["mod", 2, 3], 4], "output": "2 % 3 * 4" }, |
70 | | - { "input": ["add", 2, 3, 4], "output": "2 + 3 + 4" }, |
71 | | - { "input": ["add", ["add", 2, 3], 4], "output": "(2 + 3) + 4" }, |
| 69 | + { "input": ["add", ["add", 2, 3], 4], "output": "2 + 3 + 4" }, |
72 | 70 | { "input": ["add", 2, ["add", 3, 4]], "output": "2 + (3 + 4)" }, |
73 | | - { "input": ["subtract", 2, 3, 4], "output": "2 - 3 - 4" }, |
74 | | - { "input": ["subtract", ["subtract", 2, 3], 4], "output": "(2 - 3) - 4" }, |
| 71 | + { "input": ["subtract", ["subtract", 2, 3], 4], "output": "2 - 3 - 4" }, |
75 | 72 | { "input": ["subtract", 2, ["subtract", 3, 4]], "output": "2 - (3 - 4)" }, |
76 | 73 | { "input": ["subtract", ["add", 2, 3], 4], "output": "2 + 3 - 4" }, |
77 | 74 | { "input": ["subtract", 2, ["add", 3, 4]], "output": "2 - (3 + 4)" }, |
78 | | - { "input": ["add", ["subtract", 2, 3], 4], "output": "2 - 3 + 4" } |
| 75 | + { "input": ["add", ["subtract", 2, 3], 4], "output": "2 - 3 + 4" }, |
| 76 | + { "input": ["eq", ["eq", 2, 3], 4], "output": "(2 == 3) == 4" }, |
| 77 | + { "input": ["eq", 2, ["eq", 3, 4]], "output": "2 == (3 == 4)" } |
79 | 78 | ] |
80 | 79 | }, |
81 | 80 | { |
|
86 | 85 | { "input": ["multiply", ["pow", 2, 3], 4], "output": "2 ^ 3 * 4" }, |
87 | 86 | { "input": ["multiply", 2, ["pow", 3, 4]], "output": "2 * 3 ^ 4" }, |
88 | 87 | { "input": ["pow", 2, ["multiply", 3, 4]], "output": "2 ^ (3 * 4)" }, |
| 88 | + { "input": ["pow", ["multiply", 2, 3], 4], "output": "(2 * 3) ^ 4" }, |
89 | 89 | { "input": ["add", ["multiply", 2, 3], 4], "output": "2 * 3 + 4" }, |
90 | 90 | { "input": ["add", 2, ["multiply", 3, 4]], "output": "2 + 3 * 4" }, |
91 | 91 | { "input": ["multiply", 2, ["add", 3, 4]], "output": "2 * (3 + 4)" }, |
| 92 | + { "input": ["multiply", ["add", 2, 3], 4], "output": "(2 + 3) * 4" }, |
92 | 93 | { "input": ["gt", ["add", 2, 3], 4], "output": "2 + 3 > 4" }, |
| 94 | + { "input": ["gt", 2, ["add", 3, 4]], "output": "2 > 3 + 4" }, |
93 | 95 | { "input": ["add", 2, ["gt", 3, 4]], "output": "2 + (3 > 4)" }, |
| 96 | + { "input": ["add", ["gt", 2, 3], 4], "output": "(2 > 3) + 4" }, |
94 | 97 | { "input": ["eq", ["gt", 2, 3], 4], "output": "2 > 3 == 4" }, |
95 | 98 | { "input": ["gt", 2, ["eq", 3, 4]], "output": "2 > (3 == 4)" }, |
96 | 99 | { "input": ["and", ["eq", 2, 3], 4], "output": "2 == 3 and 4" }, |
97 | 100 | { "input": ["eq", 2, ["and", 3, 4]], "output": "2 == (3 and 4)" }, |
| 101 | + { "input": ["eq", ["and", 2, 3], 4], "output": "(2 and 3) == 4" }, |
98 | 102 | { "input": ["or", ["and", 2, 3], 4], "output": "2 and 3 or 4" }, |
99 | 103 | { "input": ["and", 2, ["or", 3, 4]], "output": "2 and (3 or 4)" }, |
100 | 104 | { "input": ["and", ["gt", 2, 3], 4], "output": "2 > 3 and 4" }, |
101 | | - { "input": ["gt", 2, ["and", 3, 4]], "output": "2 > (3 and 4)" } |
102 | | - ] |
103 | | - }, |
104 | | - { |
105 | | - "category": "operator", |
106 | | - "description": "should wrap operators in without vararg support in parenthesis", |
107 | | - "tests": [ |
108 | | - { "input": ["pow", ["pow", 2, 3], 4], "output": "(2 ^ 3) ^ 4" }, |
109 | | - { "input": ["pow", 2, ["pow", 3, 4]], "output": "2 ^ (3 ^ 4)" } |
| 105 | + { "input": ["gt", 2, ["and", 3, 4]], "output": "2 > (3 and 4)" }, |
| 106 | + { "input": ["gt", ["and", 2, 3], 4], "output": "(2 and 3) > 4" }, |
| 107 | + { "input": ["pipe", ["and", 2, 3], 4], "output": "2 and 3 | 4" }, |
| 108 | + { "input": ["pipe", 2, ["and", 3, 4]], "output": "2 | 3 and 4" }, |
| 109 | + { "input": ["and", ["pipe", 2, 3], 4], "output": "(2 | 3) and 4" }, |
| 110 | + { "input": ["and", 2, ["pipe", 3, 4]], "output": "2 and (3 | 4)" } |
110 | 111 | ] |
111 | 112 | }, |
112 | 113 | { |
|
0 commit comments