tests: base_closure11 complex stacked and nested closure
authorJean Privat <jean@pryen.org>
Sat, 4 Jul 2009 02:54:45 +0000 (22:54 -0400)
committerJean Privat <jean@pryen.org>
Sat, 4 Jul 2009 02:54:45 +0000 (22:54 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

tests/base_closure11.nit [new file with mode: 0644]
tests/sav/base_closure11.sav [new file with mode: 0644]
tests/sav/base_closure11_alt1.sav [new file with mode: 0644]
tests/sav/base_closure11_alt2.sav [new file with mode: 0644]

diff --git a/tests/base_closure11.nit b/tests/base_closure11.nit
new file mode 100644 (file)
index 0000000..46f3d0f
--- /dev/null
@@ -0,0 +1,60 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2009 Jean Privat <jean@pryen.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
+
+fun foo
+       with x
+do
+       'F'.output
+       0.output
+       bar with do
+               'F'.output
+               1.output
+               x
+               'F'.output
+               1.output
+       end
+       'F'.output
+       0.output
+end
+
+fun bar
+       with y
+do
+       'B'.output
+       0.output
+       y
+       'B'.output
+       0.output
+end
+
+'M'.output
+0.output
+foo with do
+       'M'.output
+       1.output
+       foo with do
+               'M'.output
+               2.output
+               #alt1#break
+               #alt2#return
+       end
+       'M'.output
+       1.output
+end
+'M'.output
+0.output
diff --git a/tests/sav/base_closure11.sav b/tests/sav/base_closure11.sav
new file mode 100644 (file)
index 0000000..fef004f
--- /dev/null
@@ -0,0 +1,17 @@
+M0
+F0
+B0
+F1
+M1
+F0
+B0
+F1
+M2
+F1
+B0
+F0
+M1
+F1
+B0
+F0
+M0
diff --git a/tests/sav/base_closure11_alt1.sav b/tests/sav/base_closure11_alt1.sav
new file mode 100644 (file)
index 0000000..853a6af
--- /dev/null
@@ -0,0 +1,14 @@
+M0
+F0
+B0
+F1
+M1
+F0
+B0
+F1
+M2
+M1
+F1
+B0
+F0
+M0
diff --git a/tests/sav/base_closure11_alt2.sav b/tests/sav/base_closure11_alt2.sav
new file mode 100644 (file)
index 0000000..49cfa3d
--- /dev/null
@@ -0,0 +1,9 @@
+M0
+F0
+B0
+F1
+M1
+F0
+B0
+F1
+M2