From 0830b5bf24a7117130e0089754cd96e51411284d Mon Sep 17 00:00:00 2001 From: Or Brostovski Date: Sat, 21 Aug 2010 02:41:43 +0300 Subject: Modified parser to handle alt type andadded a few tests ast.ml - modified arm types for easier polymorphism - fixed a bug in fmt_type_arm dead.ml - modified arm types for easier polymorphism common.ml - added 'either' - added some useful auxiliary functions item.ml - modified arm code to be more polymorphic and handle both alt-tag and alt-type, also fixed the problematic case in bad-alt.rs Makefile - added XFAIL for new alt-type test bad-alt.rs - added test for invalid alt syntax alt-type-simple.rs - added simple test for alt type --- src/test/compile-fail/bad-alt.rs | 6 ++++++ src/test/run-pass/alt-type-simple.rs | 11 +++++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/test/compile-fail/bad-alt.rs create mode 100644 src/test/run-pass/alt-type-simple.rs (limited to 'src/test') diff --git a/src/test/compile-fail/bad-alt.rs b/src/test/compile-fail/bad-alt.rs new file mode 100644 index 00000000..f2582879 --- /dev/null +++ b/src/test/compile-fail/bad-alt.rs @@ -0,0 +1,6 @@ +// error-pattern: Unexpected token 'x' + +fn main() { + let int x = 5; + alt x; +} diff --git a/src/test/run-pass/alt-type-simple.rs b/src/test/run-pass/alt-type-simple.rs new file mode 100644 index 00000000..85f6ff68 --- /dev/null +++ b/src/test/run-pass/alt-type-simple.rs @@ -0,0 +1,11 @@ +fn altsimple(any x) { + alt type (f) { + case (int i) { print("int"); } + case (str s) { print("str"); } + } +} + +fn main() { + altsimple(5); + altsimple("asdfasdfsDF"); +} -- cgit v1.2.3