zeolite-lang-0.10.0.0: tests/unreachable.0rt
/* -----------------------------------------------------------------------------
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 "warning statement after fail" {
compiles
require compiler "unreachable"
}
concrete Test {}
define Test {
@category failedReturn () -> (Int)
failedReturn () {
fail("Failed")
return 1
}
}
testcase "unreachable not compiled" {
compiles
}
concrete Test {}
define Test {
@category failedReturn () -> (Int)
failedReturn () {
fail("Failed")
\ foo()
}
}
testcase "warning statement after return" {
compiles
require compiler "unreachable"
}
concrete Test {}
define Test {
@category failedReturn () -> (Int)
failedReturn () {
return 0
return 1
}
}
testcase "warning statement after conditional return" {
compiles
require compiler "unreachable"
}
concrete Test {}
define Test {
@category failedReturn () -> (Int)
failedReturn () {
if (true) {
return 1
} else {
return 2
}
return 3
}
}
testcase "warning statement after scoped return" {
compiles
require compiler "unreachable"
}
concrete Test {}
define Test {
@category failedReturn () -> (Int)
failedReturn () {
scoped {
return 1
} in return 2
}
}
testcase "warning statement after cleanup fail" {
crash
require compiler "unreachable"
require "message"
}
unittest test {
\ Test:failedReturn()
}
concrete Test {
@category failedReturn () -> (Int)
}
define Test {
failedReturn () {
scoped {
} cleanup {
fail("message")
} in \ empty
return 2
}
}
testcase "warning statement in cleanup after scoped fail" {
crash
require compiler "unreachable"
require "message"
}
unittest test {
\ Test:failedReturn()
}
concrete Test {
@category failedReturn () -> ()
}
define Test {
failedReturn () {
scoped {
fail("message")
} cleanup {
\ empty
} in {}
}
}
testcase "warning statement in cleanup after in fail" {
crash
require compiler "unreachable"
require "message"
}
unittest test {
\ Test:failedReturn()
}
concrete Test {
@category failedReturn () -> ()
}
define Test {
failedReturn () {
cleanup {
\ empty
} in fail("message")
}
}
testcase "warning statement after break" {
compiles
require compiler "unreachable"
}
unittest test {
while (false) {
break
fail("Failed")
}
}
testcase "warning statement after continue" {
compiles
require compiler "unreachable"
}
unittest test {
while (false) {
continue
fail("Failed")
}
}