/* ----------------------------------------------------------------------------- Copyright 2020 Kevin P. Barry Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ----------------------------------------------------------------------------- */ // Author: Kevin P. Barry [ta0kira@gmail.com] testcase "bad macro name" { error require "UNKNOWN_STRING .+not defined" } define Test { run () { String value <- $ExprLookup[UNKNOWN_STRING]$ } } concrete Test { @type run () -> () } testcase "MODULE_PATH is absolute" { crash Test$run() require "Failed condition: /.+/tests" } define Test { run () { fail($ExprLookup[MODULE_PATH]$) } } concrete Test { @type run () -> () } testcase "MODULE_PATH from regular source" { crash Test$run() require "Failed condition: /.+/tests" } define Test { run () { fail(ExprLookup$modulePath()) } } concrete Test { @type run () -> () } testcase "mismatched macro type" { error require "String.+Int" } define Test { run () { Int value <- $ExprLookup[MODULE_PATH]$ } } concrete Test { @type run () -> () } testcase "macro used inline in expressions" { crash Test$run() require "Failed condition: /.+/tests is the path" } define Test { run () { fail($ExprLookup[MODULE_PATH]$ + " is the path") } } concrete Test { @type run () -> () } testcase "constant defined in .zeolite-module" { success Test$run() } define Test { run () { \ Testing$check($ExprLookup[INT_EXPR]$,4) } } concrete Test { @type run () -> () } testcase "constant defined in .zeolite-module from regular source" { success Test$run() } define Test { run () { \ Testing$check(ExprLookup$intExpr(),4) } } concrete Test { @type run () -> () } testcase "in context defined in .zeolite-module" { success Test$run() } define Test { @category String macroLocalVar <- "hello" run () { \ Testing$check($ExprLookup[LOCAL_VAR]$,"hello") } } concrete Test { @type run () -> () } testcase "undefined in context defined in .zeolite-module" { error require "\.zeolite-module" require "macroLocalVar" } define Test { run () { String value <- $ExprLookup[LOCAL_VAR]$ } } concrete Test { @type run () -> () } testcase "in context defined in .zeolite-module from regular source" { success Test$run() } define Test { run () { \ Testing$check(ExprLookup$localVar(),99) } } concrete Test { @type run () -> () } testcase "nested expression defined in .zeolite-module" { success Test$run() } define Test { run () { \ Testing$check($ExprLookup[META_VAR]$,20) } } concrete Test { @type run () -> () } testcase "function called on expression" { success Test$run() } define Test { run () { \ Testing$check($ExprLookup[INT_EXPR]$.formatted(),"4") } } concrete Test { @type run () -> () }