post operators test

This commit is contained in:
Umur Ozkul 2022-05-19 17:47:26 +02:00
parent 56f0c9c290
commit 3371c51e94

View File

@ -61,7 +61,6 @@ describe("Peggy parse", () => {
testParse("1 * 2 - 3 ./ 4", "{(::subtract (::multiply 1 2) (::dotDivide 3 4))}")
testParse("1 * 2 - 3 * 4^5", "{(::subtract (::multiply 1 2) (::multiply 3 (::pow 4 5)))}")
testParse("1 * 2 - 3 * 4^5^6", "{(::subtract (::multiply 1 2) (::multiply 3 (::pow (::pow 4 5) 6)))}")
testParse("1 * 2 - 3 * 4^5^6", "{(::subtract (::multiply 1 2) (::multiply 3 (::pow (::pow 4 5) 6)))}")
testParse("1 * -a[-2]", "{(::multiply 1 (::unaryMinus (::$atIndex :a (::unaryMinus 2))))}")
})
@ -94,6 +93,13 @@ describe("Peggy parse", () => {
testParse("record.property", "{(::$atIndex :record 'property')}")
})
describe("post operators", ()=>{
//function call, array and record access are post operators with higher priority than unary operators
testParse("a==!b(1)", "{(::equal :a (::not (::b 1)))}")
testParse("a==!b[1]", "{(::equal :a (::not (::$atIndex :b 1)))}")
testParse("a==!b.one", "{(::equal :a (::not (::$atIndex :b 'one')))}")
})
describe("comments", () => {
testParse("1 # This is a line comment", "{1}")
testParse("1 // This is a line comment", "{1}")