zeolite-lang-0.23.0.0: tests/simple.0rt
/* -----------------------------------------------------------------------------
Copyright 2020,2022 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 "basic compiles test" {
compiles
require compiler "unreachable"
}
unittest test {
return _
\ empty
}
testcase "basic error test" {
error
require compiler "category.+undefined"
require compiler "type.+undefined"
exclude stderr "."
exclude stdout "."
}
concrete Test {
@type execute () -> ()
}
define Test {
execute () {
\ undefined()
}
}
testcase "basic crash test" {
crash
require stderr "testcase:"
require stderr "failure message!!!"
exclude stdout "failure message!!!"
}
unittest test {
// NOTE: "!!!" is important here because it also tests mixing of escaped and
// unescaped characters when handling string literals.
fail("failure message!!!")
}
testcase "basic success test" {
success
}
unittest test {
return _
}
testcase "minimal linking works properly" {
success
}
unittest test {
\ empty
}
testcase "attempt to define outside of this module" {
error
require "String"
require "module"
exclude "procedure definition"
}
// The declaration for String is in scope, but it lives outside of this module.
define String {}
testcase "attempt to define interface" {
error
require "Type"
require "concrete"
}
@value interface Type {}
define Type {}
testcase "no deadlock with recursive type" {
success
}
unittest test {
\ Type<Type<Type<Int>>>.call()
}
concrete Type<#x> {
@type call () -> ()
}
define Type {
call () {}
}
testcase "ModuleOnly is visible to tests" {
success
}
unittest test {
optional ModuleOnly value <- empty
}
testcase "custom timeout works as expected" {
crash
require "signal 14"
timeout 1
}
unittest test {
while (true) {}
}
testcase "args escaped properly" {
success
// If the compiler uses quotes without escaping individual characters then
// main will exit with an error without executing the test.
args "\" }; exit(1); const char fake[] = { \""
}
unittest test {}