Merge remote-tracking branch 'upstream/master' into init_auto
[nit.git] / tests / test_catch_runtime.nit
similarity index 51%
rename from tests/test_ropes_buffer_clear.nit
rename to tests/test_catch_runtime.nit
index 4293f8b..6c676a7 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# Checks if `RopeBuffer.clear` actually reset everything.
-module test_ropes_buffer_clear
-
-import core
-
-var buffer = new RopeBuffer
-
-buffer.append "1"
-# Force to flush the internal buffer, so that all the internal positions will be
-# set to a non-zero value.
-buffer.append("?" * (maxlen + 1))
-buffer.clear
-buffer.append "23"
-print buffer
-
-buffer = new RopeBuffer
-buffer.append "12"
-# Force to flush the internal buffer, so that all the internal positions will be
-# set to a non-zero value.
-buffer.append("?" * (maxlen + 1))
-buffer.clear
-buffer.append "3"
-print buffer
+import core::kernel
+
+fun foo is abstract
+fun bar is intern
+
+class A
+       var a: A is noautoinit
+       fun foo do 0.output
+end
+
+var a = new A
+var n: nullable A = null
+var o: Object = 1
+
+do
+       1.output
+       if true then abort
+       666.output
+catch
+       1.output
+end
+
+do
+       2.output
+       n.foo
+       666.output
+catch
+       2.output
+end
+
+do
+       3.output
+       foo
+       666.output
+catch
+       3.output
+end
+
+do
+       4.output
+       assert false
+       666.output
+catch
+       4.output
+end
+
+do
+       5.output
+       o.as(A).foo
+       666.output
+catch
+       5.output
+end
+
+do
+       6.output
+       a.a.foo
+       666.output
+catch
+       6.output
+end
+
+do
+       7.output
+       bar
+       666.output
+catch
+       7.output
+end