Added a future folder to examples
authorDavid Kerkeslager <kerkeslager@gmail.com>
Fri, 1 Sep 2017 21:49:00 +0000 (17:49 -0400)
committerDavid Kerkeslager <kerkeslager@gmail.com>
Fri, 1 Sep 2017 21:49:00 +0000 (17:49 -0400)
examples/future/30_exception.fur [new file with mode: 0644]
examples/future/31_stack_trace.fur [new file with mode: 0644]
examples/future/32_finally.fur [new file with mode: 0644]
examples/future/33_except.fur [new file with mode: 0644]
examples/future/34_except_finally.fur [new file with mode: 0644]

diff --git a/examples/future/30_exception.fur b/examples/future/30_exception.fur
new file mode 100644 (file)
index 0000000..3a55ab3
--- /dev/null
@@ -0,0 +1,3 @@
+variable = 42 // 0
+
+print('This should not print')
diff --git a/examples/future/31_stack_trace.fur b/examples/future/31_stack_trace.fur
new file mode 100644 (file)
index 0000000..21335a8
--- /dev/null
@@ -0,0 +1,7 @@
+def throws() do
+  42 // 0
+end
+
+variable = throws()
+
+print('This should not print')
diff --git a/examples/future/32_finally.fur b/examples/future/32_finally.fur
new file mode 100644 (file)
index 0000000..f89d949
--- /dev/null
@@ -0,0 +1,11 @@
+def throws() do
+  try
+    42 // 0
+  finally
+    print('This should print')
+  end
+end
+
+variable = throws()
+
+print('This should not print')
diff --git a/examples/future/33_except.fur b/examples/future/33_except.fur
new file mode 100644 (file)
index 0000000..76e900c
--- /dev/null
@@ -0,0 +1,13 @@
+def throws() do
+  try
+    42 // 0
+  except(DivisionByZeroError)
+    print('This should print\n')
+    42
+  end
+end
+
+variable = throws()
+
+print('This should also print\n')
+print('This should be 42: ', variable, '\n')
diff --git a/examples/future/34_except_finally.fur b/examples/future/34_except_finally.fur
new file mode 100644 (file)
index 0000000..d1aea97
--- /dev/null
@@ -0,0 +1,15 @@
+def throws() do
+  try
+    42 // 0
+  except(DivisionByZeroError)
+    print('This should print first\n')
+    42
+  finally
+    print('This should print second\n')
+    1
+  end
+end
+
+variable = throws()
+print('This should print third\n')
+print('This shoudld be 42: ', variable, '\n')