@fincity/kirun-js 2.1.4 → 2.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/engine/function/system/IfTest.ts +51 -0
- package/__tests__/engine/runtime/KIRuntimeVariableArgDefaultNullTest.ts +294 -0
- package/__tests__/engine/runtime/expression/ExpressionEvaluationTest.ts +118 -22
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/engine/function/system/If.ts +5 -5
- package/src/engine/model/Parameter.ts +1 -1
- package/src/engine/runtime/KIRuntime.ts +3 -3
- package/src/engine/runtime/expression/ExpressionEvaluator.ts +8 -2
- package/src/engine/runtime/expression/operators/binary/LogicalAndOperator.ts +1 -14
- package/src/engine/runtime/expression/operators/binary/LogicalOrOperator.ts +1 -14
- package/src/engine/runtime/expression/tokenextractor/TokenValueExtractor.ts +4 -3
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FunctionExecutionParameters,
|
|
3
|
+
KIRunFunctionRepository,
|
|
4
|
+
KIRunSchemaRepository,
|
|
5
|
+
} from '../../../../src';
|
|
6
|
+
import { If } from '../../../../src/engine/function/system/If';
|
|
7
|
+
|
|
8
|
+
const ifFunction = new If();
|
|
9
|
+
|
|
10
|
+
test('if test', async () => {
|
|
11
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
12
|
+
new KIRunFunctionRepository(),
|
|
13
|
+
new KIRunSchemaRepository(),
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
let fo = await ifFunction.execute(fep.setArguments(new Map([['condition', true]])));
|
|
17
|
+
expect(fo.allResults()[0].getName()).toBe('true');
|
|
18
|
+
|
|
19
|
+
fo = await ifFunction.execute(fep.setArguments(new Map([['condition', false]])));
|
|
20
|
+
expect(fo.allResults()[0].getName()).toBe('false');
|
|
21
|
+
|
|
22
|
+
fo = await ifFunction.execute(fep.setArguments(new Map([['condition', undefined]])));
|
|
23
|
+
expect(fo.allResults()[0].getName()).toBe('false');
|
|
24
|
+
|
|
25
|
+
fo = await ifFunction.execute(fep.setArguments(new Map([['condition', null]])));
|
|
26
|
+
expect(fo.allResults()[0].getName()).toBe('false');
|
|
27
|
+
|
|
28
|
+
fo = await ifFunction.execute(fep.setArguments(new Map([['condition', '']]))); // empty string
|
|
29
|
+
expect(fo.allResults()[0].getName()).toBe('true');
|
|
30
|
+
|
|
31
|
+
fo = await ifFunction.execute(fep.setArguments(new Map([['condition', ' ']]))); // space
|
|
32
|
+
expect(fo.allResults()[0].getName()).toBe('true');
|
|
33
|
+
|
|
34
|
+
fo = await ifFunction.execute(fep.setArguments(new Map([['condition', 'abc']])));
|
|
35
|
+
expect(fo.allResults()[0].getName()).toBe('true');
|
|
36
|
+
|
|
37
|
+
fo = await ifFunction.execute(fep.setArguments(new Map([['condition', 0]])));
|
|
38
|
+
expect(fo.allResults()[0].getName()).toBe('false');
|
|
39
|
+
|
|
40
|
+
fo = await ifFunction.execute(fep.setArguments(new Map([['condition', 1]])));
|
|
41
|
+
expect(fo.allResults()[0].getName()).toBe('true');
|
|
42
|
+
|
|
43
|
+
fo = await ifFunction.execute(fep.setArguments(new Map([['condition', -1]])));
|
|
44
|
+
expect(fo.allResults()[0].getName()).toBe('true');
|
|
45
|
+
|
|
46
|
+
fo = await ifFunction.execute(fep.setArguments(new Map([['condition', {}]])));
|
|
47
|
+
expect(fo.allResults()[0].getName()).toBe('true');
|
|
48
|
+
|
|
49
|
+
fo = await ifFunction.execute(fep.setArguments(new Map([['condition', []]])));
|
|
50
|
+
expect(fo.allResults()[0].getName()).toBe('true');
|
|
51
|
+
});
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AbstractFunction,
|
|
3
|
+
EventResult,
|
|
4
|
+
Function,
|
|
5
|
+
FunctionOutput,
|
|
6
|
+
FunctionSignature,
|
|
7
|
+
HybridRepository,
|
|
8
|
+
Parameter,
|
|
9
|
+
Schema,
|
|
10
|
+
SchemaType,
|
|
11
|
+
} from '../../../src';
|
|
12
|
+
import { FunctionDefinition } from '../../../src/engine/model/FunctionDefinition';
|
|
13
|
+
import { Namespaces } from '../../../src/engine/namespaces/Namespaces';
|
|
14
|
+
import { KIRunFunctionRepository } from '../../../src/engine/repository/KIRunFunctionRepository';
|
|
15
|
+
import { KIRunSchemaRepository } from '../../../src/engine/repository/KIRunSchemaRepository';
|
|
16
|
+
import { FunctionExecutionParameters } from '../../../src/engine/runtime/FunctionExecutionParameters';
|
|
17
|
+
import { KIRuntime } from '../../../src/engine/runtime/KIRuntime';
|
|
18
|
+
|
|
19
|
+
test('KIRuntime Print function with no arguments', async () => {
|
|
20
|
+
var def = {
|
|
21
|
+
name: 'varArgWithNothing',
|
|
22
|
+
namespace: 'Test',
|
|
23
|
+
steps: {
|
|
24
|
+
testFunction: {
|
|
25
|
+
statementName: 'testFunction',
|
|
26
|
+
namespace: 'LocalFunction',
|
|
27
|
+
name: 'Other',
|
|
28
|
+
parameterMap: {
|
|
29
|
+
storageName: {
|
|
30
|
+
one: {
|
|
31
|
+
type: 'VALUE',
|
|
32
|
+
value: 'Test',
|
|
33
|
+
key: 'one',
|
|
34
|
+
order: 1,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
var OtherFunction = new KIRuntime(
|
|
43
|
+
FunctionDefinition.from({
|
|
44
|
+
namespace: 'LocalFunction',
|
|
45
|
+
name: 'Other',
|
|
46
|
+
steps: {
|
|
47
|
+
print: {
|
|
48
|
+
statementName: 'print',
|
|
49
|
+
namespace: Namespaces.SYSTEM,
|
|
50
|
+
name: 'Print',
|
|
51
|
+
parameterMap: {
|
|
52
|
+
values: {
|
|
53
|
+
one: {
|
|
54
|
+
type: 'EXPRESSION',
|
|
55
|
+
expression: '"Storage : " + Arguments.storageName + "\n"',
|
|
56
|
+
key: 'one',
|
|
57
|
+
order: 1,
|
|
58
|
+
},
|
|
59
|
+
two: {
|
|
60
|
+
type: 'EXPRESSION',
|
|
61
|
+
expression: '"Page : " + Arguments.page + "\n"',
|
|
62
|
+
key: 'two',
|
|
63
|
+
order: 2,
|
|
64
|
+
},
|
|
65
|
+
three: {
|
|
66
|
+
type: 'EXPRESSION',
|
|
67
|
+
expression: '"Size : " + Arguments.size + "\n"',
|
|
68
|
+
key: 'three',
|
|
69
|
+
order: 3,
|
|
70
|
+
},
|
|
71
|
+
five: {
|
|
72
|
+
type: 'EXPRESSION',
|
|
73
|
+
expression: '"Count : " + Arguments.count + "\n"',
|
|
74
|
+
key: 'five',
|
|
75
|
+
order: 5,
|
|
76
|
+
},
|
|
77
|
+
six: {
|
|
78
|
+
type: 'EXPRESSION',
|
|
79
|
+
expression: '"Client Code : " + Arguments.clientCode + "\n"',
|
|
80
|
+
key: 'six',
|
|
81
|
+
order: 6,
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
eight: {
|
|
85
|
+
type: 'EXPRESSION',
|
|
86
|
+
expression: '"Eager : " + Arguments.eager + "\n"',
|
|
87
|
+
key: 'eight',
|
|
88
|
+
order: 8,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
parameters: {
|
|
95
|
+
appCode: {
|
|
96
|
+
schema: {
|
|
97
|
+
namespace: '_',
|
|
98
|
+
name: 'appCode',
|
|
99
|
+
version: 1,
|
|
100
|
+
type: {
|
|
101
|
+
type: 'STRING',
|
|
102
|
+
},
|
|
103
|
+
defaultValue: '',
|
|
104
|
+
},
|
|
105
|
+
parameterName: 'appCode',
|
|
106
|
+
variableArgument: false,
|
|
107
|
+
type: 'EXPRESSION',
|
|
108
|
+
},
|
|
109
|
+
page: {
|
|
110
|
+
schema: {
|
|
111
|
+
namespace: '_',
|
|
112
|
+
name: 'page',
|
|
113
|
+
version: 1,
|
|
114
|
+
type: {
|
|
115
|
+
type: 'INTEGER',
|
|
116
|
+
},
|
|
117
|
+
defaultValue: 0,
|
|
118
|
+
},
|
|
119
|
+
parameterName: 'page',
|
|
120
|
+
variableArgument: false,
|
|
121
|
+
type: 'EXPRESSION',
|
|
122
|
+
},
|
|
123
|
+
storageName: {
|
|
124
|
+
schema: {
|
|
125
|
+
namespace: '_',
|
|
126
|
+
name: 'storageName',
|
|
127
|
+
version: 1,
|
|
128
|
+
type: {
|
|
129
|
+
type: 'STRING',
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
parameterName: 'storageName',
|
|
133
|
+
variableArgument: false,
|
|
134
|
+
type: 'EXPRESSION',
|
|
135
|
+
},
|
|
136
|
+
size: {
|
|
137
|
+
schema: {
|
|
138
|
+
namespace: '_',
|
|
139
|
+
name: 'size',
|
|
140
|
+
version: 1,
|
|
141
|
+
type: {
|
|
142
|
+
type: 'INTEGER',
|
|
143
|
+
},
|
|
144
|
+
defaultValue: 20,
|
|
145
|
+
},
|
|
146
|
+
parameterName: 'size',
|
|
147
|
+
variableArgument: false,
|
|
148
|
+
type: 'EXPRESSION',
|
|
149
|
+
},
|
|
150
|
+
count: {
|
|
151
|
+
schema: {
|
|
152
|
+
namespace: '_',
|
|
153
|
+
name: 'count',
|
|
154
|
+
version: 1,
|
|
155
|
+
type: {
|
|
156
|
+
type: 'BOOLEAN',
|
|
157
|
+
},
|
|
158
|
+
defaultValue: true,
|
|
159
|
+
},
|
|
160
|
+
parameterName: 'count',
|
|
161
|
+
variableArgument: false,
|
|
162
|
+
type: 'EXPRESSION',
|
|
163
|
+
},
|
|
164
|
+
clientCode: {
|
|
165
|
+
schema: {
|
|
166
|
+
namespace: '_',
|
|
167
|
+
name: 'clientCode',
|
|
168
|
+
version: 1,
|
|
169
|
+
type: {
|
|
170
|
+
type: 'STRING',
|
|
171
|
+
},
|
|
172
|
+
defaultValue: '',
|
|
173
|
+
},
|
|
174
|
+
parameterName: 'clientCode',
|
|
175
|
+
variableArgument: false,
|
|
176
|
+
type: 'EXPRESSION',
|
|
177
|
+
},
|
|
178
|
+
eagerFields: {
|
|
179
|
+
schema: {
|
|
180
|
+
namespace: '_',
|
|
181
|
+
name: 'eagerFields',
|
|
182
|
+
version: 1,
|
|
183
|
+
type: {
|
|
184
|
+
type: 'STRING',
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
parameterName: 'eagerFields',
|
|
188
|
+
variableArgument: true,
|
|
189
|
+
type: 'EXPRESSION',
|
|
190
|
+
},
|
|
191
|
+
filter: {
|
|
192
|
+
schema: {
|
|
193
|
+
namespace: '_',
|
|
194
|
+
name: 'filter',
|
|
195
|
+
version: 1,
|
|
196
|
+
type: {
|
|
197
|
+
type: 'OBJECT',
|
|
198
|
+
},
|
|
199
|
+
defaultValue: {},
|
|
200
|
+
},
|
|
201
|
+
parameterName: 'filter',
|
|
202
|
+
variableArgument: false,
|
|
203
|
+
type: 'EXPRESSION',
|
|
204
|
+
},
|
|
205
|
+
eager: {
|
|
206
|
+
schema: {
|
|
207
|
+
namespace: '_',
|
|
208
|
+
name: 'eager',
|
|
209
|
+
version: 1,
|
|
210
|
+
type: {
|
|
211
|
+
type: 'BOOLEAN',
|
|
212
|
+
},
|
|
213
|
+
defaultValue: false,
|
|
214
|
+
},
|
|
215
|
+
parameterName: 'eager',
|
|
216
|
+
variableArgument: false,
|
|
217
|
+
type: 'EXPRESSION',
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
}),
|
|
221
|
+
false,
|
|
222
|
+
);
|
|
223
|
+
const fd = FunctionDefinition.from(def);
|
|
224
|
+
const oldConsole = console.log;
|
|
225
|
+
const test = (console.log = jest.fn().mockImplementation(() => {}));
|
|
226
|
+
|
|
227
|
+
let result = await new KIRuntime(fd, false).execute(
|
|
228
|
+
new FunctionExecutionParameters(
|
|
229
|
+
new HybridRepository<Function>(new KIRunFunctionRepository(), {
|
|
230
|
+
find: async (namespace: string, name: string): Promise<Function | undefined> => {
|
|
231
|
+
if (namespace === 'LocalFunction' && name === 'Other') return OtherFunction;
|
|
232
|
+
return undefined;
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
filter: async (name: string): Promise<string[]> => {
|
|
236
|
+
return ['LocalFunction.Other'];
|
|
237
|
+
},
|
|
238
|
+
}),
|
|
239
|
+
new KIRunSchemaRepository(),
|
|
240
|
+
),
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
console.log = oldConsole;
|
|
244
|
+
|
|
245
|
+
expect(test.mock.calls[0]).toMatchObject([
|
|
246
|
+
'Storage : Test\n',
|
|
247
|
+
'Page : 0\n',
|
|
248
|
+
'Size : 20\n',
|
|
249
|
+
'Count : true\n',
|
|
250
|
+
'Client Code : \n',
|
|
251
|
+
'Eager : false\n',
|
|
252
|
+
]);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
test("KIRuntime Print function with 'null' argument", async () => {
|
|
256
|
+
class TestPrint extends AbstractFunction {
|
|
257
|
+
private static readonly VALUES: string = 'values';
|
|
258
|
+
|
|
259
|
+
private static readonly SIGNATURE: FunctionSignature = new FunctionSignature('Print')
|
|
260
|
+
.setNamespace(Namespaces.SYSTEM)
|
|
261
|
+
.setParameters(
|
|
262
|
+
new Map([
|
|
263
|
+
Parameter.ofEntry(
|
|
264
|
+
TestPrint.VALUES,
|
|
265
|
+
Schema.of(
|
|
266
|
+
TestPrint.VALUES,
|
|
267
|
+
SchemaType.STRING,
|
|
268
|
+
SchemaType.NULL,
|
|
269
|
+
).setDefaultValue(null),
|
|
270
|
+
false,
|
|
271
|
+
),
|
|
272
|
+
]),
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
public getSignature(): FunctionSignature {
|
|
276
|
+
return TestPrint.SIGNATURE;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
protected async internalExecute(
|
|
280
|
+
context: FunctionExecutionParameters,
|
|
281
|
+
): Promise<FunctionOutput> {
|
|
282
|
+
var values = context.getArguments()?.get(TestPrint.VALUES);
|
|
283
|
+
|
|
284
|
+
console?.log(values);
|
|
285
|
+
|
|
286
|
+
return new FunctionOutput([EventResult.outputOf(new Map())]);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
var fun = new TestPrint();
|
|
291
|
+
fun.execute(
|
|
292
|
+
new FunctionExecutionParameters(new KIRunFunctionRepository(), new KIRunSchemaRepository()),
|
|
293
|
+
);
|
|
294
|
+
});
|
|
@@ -244,37 +244,133 @@ test('Partial path evaluation', () => {
|
|
|
244
244
|
expect(ev.evaluate(valuesMap)).toBe(2);
|
|
245
245
|
});
|
|
246
246
|
|
|
247
|
-
test('Expression with consecutive negative operators', () => {
|
|
247
|
+
// test('Expression with consecutive negative operators', () => {
|
|
248
|
+
// let atv: ArgumentsTokenValueExtractor = new ArgumentsTokenValueExtractor(
|
|
249
|
+
// new Map<string, any>([
|
|
250
|
+
// ['a', 'kirun '],
|
|
251
|
+
// ['b', 1],
|
|
252
|
+
// ['b1', 4],
|
|
253
|
+
// ['b2', 4],
|
|
254
|
+
// ]),
|
|
255
|
+
// );
|
|
256
|
+
|
|
257
|
+
// let valuesMap: Map<string, TokenValueExtractor> = MapUtil.of(atv.getPrefix(), atv);
|
|
258
|
+
|
|
259
|
+
// let ev = new ExpressionEvaluator('Arguments.b - Arguments.b1 - Arguments.b2');
|
|
260
|
+
// expect(ev.evaluate(valuesMap)).toBe(-7);
|
|
261
|
+
// });
|
|
262
|
+
|
|
263
|
+
// test('Expression with multiple coalesce operator', () => {
|
|
264
|
+
// let atv: ArgumentsTokenValueExtractor = new ArgumentsTokenValueExtractor(
|
|
265
|
+
// new Map<string, any>([
|
|
266
|
+
// ['a', 'kirun '],
|
|
267
|
+
// ['b', 1],
|
|
268
|
+
// ['b1', 4],
|
|
269
|
+
// ['b2', 4],
|
|
270
|
+
// ]),
|
|
271
|
+
// );
|
|
272
|
+
|
|
273
|
+
// let valuesMap: Map<string, TokenValueExtractor> = MapUtil.of(atv.getPrefix(), atv);
|
|
274
|
+
|
|
275
|
+
// let ev = new ExpressionEvaluator('Arguments.b3 ?? (Arguments.b - 3) ?? Arguments.b5 ?? 4');
|
|
276
|
+
// expect(ev.evaluate(valuesMap)).toBe(-2);
|
|
277
|
+
|
|
278
|
+
// ev = new ExpressionEvaluator('Arguments.b3 ?? Arguments.b - 3 ?? Arguments.b5 ?? 4');
|
|
279
|
+
// expect(ev.evaluate(valuesMap)).toBe(-2);
|
|
280
|
+
// });
|
|
281
|
+
|
|
282
|
+
test('Expression with logical operators and all value types including object', () => {
|
|
248
283
|
let atv: ArgumentsTokenValueExtractor = new ArgumentsTokenValueExtractor(
|
|
249
284
|
new Map<string, any>([
|
|
250
|
-
['
|
|
251
|
-
['
|
|
252
|
-
['
|
|
253
|
-
['
|
|
285
|
+
['string', 'kirun '],
|
|
286
|
+
['stringEmpty', ''],
|
|
287
|
+
['number', 122.2],
|
|
288
|
+
['number0', 0],
|
|
289
|
+
['booleanTrue', true],
|
|
290
|
+
['booleanFalse', false],
|
|
291
|
+
['null', null],
|
|
292
|
+
['undefined', undefined],
|
|
293
|
+
['object', { a: 1, b: '2', c: true, d: null, e: undefined }],
|
|
294
|
+
['array', [1, '2', true, null, undefined]],
|
|
295
|
+
['array2', [1, '2', true, null, undefined]],
|
|
296
|
+
['emptyArray', []],
|
|
254
297
|
]),
|
|
255
298
|
);
|
|
256
299
|
|
|
257
300
|
let valuesMap: Map<string, TokenValueExtractor> = MapUtil.of(atv.getPrefix(), atv);
|
|
258
301
|
|
|
259
|
-
let ev = new ExpressionEvaluator('
|
|
260
|
-
expect(ev.evaluate(valuesMap)).
|
|
261
|
-
});
|
|
302
|
+
let ev = new ExpressionEvaluator('not not Arguments.object');
|
|
303
|
+
expect(ev.evaluate(valuesMap)).toBeTruthy();
|
|
262
304
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
new Map<string, any>([
|
|
266
|
-
['a', 'kirun '],
|
|
267
|
-
['b', 1],
|
|
268
|
-
['b1', 4],
|
|
269
|
-
['b2', 4],
|
|
270
|
-
]),
|
|
271
|
-
);
|
|
305
|
+
ev = new ExpressionEvaluator('not not Arguments.stringEmpty');
|
|
306
|
+
expect(ev.evaluate(valuesMap)).toBeTruthy();
|
|
272
307
|
|
|
273
|
-
|
|
308
|
+
ev = new ExpressionEvaluator('not not Arguments.number');
|
|
309
|
+
expect(ev.evaluate(valuesMap)).toBeTruthy();
|
|
310
|
+
|
|
311
|
+
ev = new ExpressionEvaluator('not not Arguments.number0');
|
|
312
|
+
expect(ev.evaluate(valuesMap)).toBeFalsy();
|
|
313
|
+
|
|
314
|
+
ev = new ExpressionEvaluator('not not Arguments.booleanTrue');
|
|
315
|
+
expect(ev.evaluate(valuesMap)).toBeTruthy();
|
|
316
|
+
|
|
317
|
+
ev = new ExpressionEvaluator('not not Arguments.booleanFalse');
|
|
318
|
+
expect(ev.evaluate(valuesMap)).toBeFalsy();
|
|
319
|
+
|
|
320
|
+
ev = new ExpressionEvaluator('not not Arguments.null');
|
|
321
|
+
expect(ev.evaluate(valuesMap)).toBeFalsy();
|
|
322
|
+
|
|
323
|
+
ev = new ExpressionEvaluator('not not Arguments.undefined');
|
|
324
|
+
expect(ev.evaluate(valuesMap)).toBeFalsy();
|
|
274
325
|
|
|
275
|
-
|
|
276
|
-
expect(ev.evaluate(valuesMap)).
|
|
326
|
+
ev = new ExpressionEvaluator('not not Arguments.array');
|
|
327
|
+
expect(ev.evaluate(valuesMap)).toBeTruthy();
|
|
328
|
+
|
|
329
|
+
ev = new ExpressionEvaluator('not not Arguments.emptyArray');
|
|
330
|
+
expect(ev.evaluate(valuesMap)).toBeTruthy();
|
|
331
|
+
|
|
332
|
+
ev = new ExpressionEvaluator('Arguments.object = true');
|
|
333
|
+
expect(ev.evaluate(valuesMap)).toBeFalsy();
|
|
334
|
+
|
|
335
|
+
ev = new ExpressionEvaluator('Arguments.object != true');
|
|
336
|
+
expect(ev.evaluate(valuesMap)).toBeTruthy();
|
|
337
|
+
|
|
338
|
+
ev = new ExpressionEvaluator('Arguments.stringEmpty = true');
|
|
339
|
+
expect(ev.evaluate(valuesMap)).toBeFalsy();
|
|
340
|
+
|
|
341
|
+
ev = new ExpressionEvaluator('Arguments.stringEmpty != false');
|
|
342
|
+
expect(ev.evaluate(valuesMap)).toBeTruthy();
|
|
343
|
+
|
|
344
|
+
ev = new ExpressionEvaluator('Arguments.number0 = true');
|
|
345
|
+
expect(ev.evaluate(valuesMap)).toBeFalsy();
|
|
346
|
+
|
|
347
|
+
ev = new ExpressionEvaluator('Arguments.number0 = false');
|
|
348
|
+
expect(ev.evaluate(valuesMap)).toBeFalsy();
|
|
349
|
+
|
|
350
|
+
ev = new ExpressionEvaluator('Arguments.array.length');
|
|
351
|
+
expect(ev.evaluate(valuesMap)).toBe(5);
|
|
352
|
+
|
|
353
|
+
ev = new ExpressionEvaluator('Arguments.object.length');
|
|
354
|
+
expect(ev.evaluate(valuesMap)).toBe(5);
|
|
355
|
+
|
|
356
|
+
ev = new ExpressionEvaluator('Arguments.object and Arguments.array');
|
|
357
|
+
expect(ev.evaluate(valuesMap)).toBeTruthy();
|
|
358
|
+
|
|
359
|
+
ev = new ExpressionEvaluator('Arguments.object or Arguments.null');
|
|
360
|
+
expect(ev.evaluate(valuesMap)).toBeTruthy();
|
|
361
|
+
|
|
362
|
+
ev = new ExpressionEvaluator('Arguments.object and Arguments.null');
|
|
363
|
+
expect(ev.evaluate(valuesMap)).toBeFalsy();
|
|
364
|
+
|
|
365
|
+
ev = new ExpressionEvaluator('Arguments.object ? 3 : 4');
|
|
366
|
+
expect(ev.evaluate(valuesMap)).toBe(3);
|
|
367
|
+
|
|
368
|
+
ev = new ExpressionEvaluator('not Arguments.object ? 3 : 4');
|
|
369
|
+
expect(ev.evaluate(valuesMap)).toBe(4);
|
|
370
|
+
|
|
371
|
+
ev = new ExpressionEvaluator('Arguments.array = Arguments.array2');
|
|
372
|
+
expect(ev.evaluate(valuesMap)).toBeTruthy();
|
|
277
373
|
|
|
278
|
-
ev = new ExpressionEvaluator('Arguments.
|
|
279
|
-
expect(ev.evaluate(valuesMap)).toBe(
|
|
374
|
+
ev = new ExpressionEvaluator('Arguments.number0 ? 3 : 4');
|
|
375
|
+
expect(ev.evaluate(valuesMap)).toBe(4);
|
|
280
376
|
});
|