Skip to content

Commit 0acaf7e

Browse files
test: 'check arithmetic var in and'
terminusdb/terminusdb#2156
1 parent a349e94 commit 0acaf7e

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

test/woql.spec.js

+60
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ describe('woql queries', () => {
486486
}
487487
})
488488
});
489+
489490
it('check deep arithmetic var', () => {
490491
let v = Vars("a", "res");
491492
const wq = WOQL.and(
@@ -496,4 +497,63 @@ describe('woql queries', () => {
496497
expect(wq).to.deep.eql(
497498
{"@type":"And","and":[{"@type":"Eval","expression":{"@type":"Times","left":{"@type":"ArithmeticValue","data":{"@type":"xsd:decimal","@value":3}},"right":{"@type":"ArithmeticValue","data":{"@type":"xsd:decimal","@value":4}}},"result":{"@type":"ArithmeticValue","variable":"a"}},{"@type":"Eval","expression":{"@type":"Times","left":{"@type":"ArithmeticValue","variable":"a"},"right":{"@type":"ArithmeticValue","data":{"@type":"xsd:decimal","@value":3}}},"result":{"@type":"ArithmeticValue","variable":"res"}}]})
498499
});
500+
501+
it('check arithmetic var in and', () => {
502+
let v = Vars("result1", "result2");
503+
const wq = WOQL.and(
504+
WOQL.eval(WOQL.times(2,3), v.result1),
505+
WOQL.eval(WOQL.times(v.result1,3), v.result2)
506+
).json();
507+
expect(wq).to.deep.eql({
508+
"@type": "And",
509+
"and": [
510+
{
511+
"@type": "Eval",
512+
"expression": {
513+
"@type": "Times",
514+
"left": {
515+
"@type": "ArithmeticValue",
516+
"data": {
517+
"@type": "xsd:decimal",
518+
"@value": 2
519+
}
520+
},
521+
"right": {
522+
"@type": "ArithmeticValue",
523+
"data": {
524+
"@type": "xsd:decimal",
525+
"@value": 3
526+
}
527+
}
528+
},
529+
"result": {
530+
"@type": "ArithmeticValue",
531+
"variable": "result1"
532+
}
533+
},
534+
{
535+
"@type": "Eval",
536+
"expression": {
537+
"@type": "Times",
538+
"left": {
539+
"@type": "ArithmeticValue",
540+
"variable": "result1"
541+
},
542+
"right": {
543+
"@type": "ArithmeticValue",
544+
"data": {
545+
"@type": "xsd:decimal",
546+
"@value": 3
547+
}
548+
}
549+
},
550+
"result": {
551+
"@type": "ArithmeticValue",
552+
"variable": "result2"
553+
}
554+
}
555+
]
556+
});
557+
});
558+
499559
});

0 commit comments

Comments
 (0)