/* ----------------------------------------------------------------------------- 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" } unittest test { fail("Failed") \ empty } testcase "unreachable not compiled" { compiles require compiler "unreachable" } unittest test { 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 "unreachable in cleanup does not affect in block" { error require compiler "foo" } unittest test { scoped { } cleanup { fail("message") } in \ foo() } testcase "warning statement after cleanup fail" { compiles require compiler "unreachable" } unittest test { scoped { } cleanup { fail("message") } in \ empty \ foo() } testcase "warning statement in cleanup after scoped fail" { compiles require compiler "unreachable" } unittest test { scoped { fail("message") } cleanup { \ empty } in {} } testcase "no warning statement in cleanup after in fail" { compiles exclude compiler "unreachable" } unittest test { 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") } }