diff --git a/tests/base_control_flow3.nit b/tests/base_control_flow3.nit new file mode 100644 index 0000000000..1e17ae1871 --- /dev/null +++ b/tests/base_control_flow3.nit @@ -0,0 +1,49 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# 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. + +import kernel + +var a +a = null +a = 1 + +a.output +return +# Below this line the code is unreachable + +var b +b = null +b = 1 +a.output +b.output +a = b +b = a + +if a == b then + a = b + b = a +else + a = null + b = null +end +a.output +b.output +var c = a.as(not null) +var d = b.as(Int) +var e +e.output + +#alt1#(b+1).output # Error +b = 1 +#alt1#(b+1).output # Still error diff --git a/tests/sav/base_control_flow3.res b/tests/sav/base_control_flow3.res new file mode 100644 index 0000000000..e3ec4cf81b --- /dev/null +++ b/tests/sav/base_control_flow3.res @@ -0,0 +1,2 @@ +base_control_flow3.nit:25,1--5: Warning: unreachable statement. +1 diff --git a/tests/sav/base_control_flow3_alt1.res b/tests/sav/base_control_flow3_alt1.res new file mode 100644 index 0000000000..25a65d9e64 --- /dev/null +++ b/tests/sav/base_control_flow3_alt1.res @@ -0,0 +1,3 @@ +alt/base_control_flow3_alt1.nit:25,1--5: Warning: unreachable statement. +alt/base_control_flow3_alt1.nit:47,3: Error: method `+` does not exists in `nullable Object`. +alt/base_control_flow3_alt1.nit:49,3: Error: method `+` does not exists in `nullable Object`.