From 0fe9c0a9d11e64f556fcdee8296d7ae43c7fcd35 Mon Sep 17 00:00:00 2001 From: Lindsey Kuper Date: Thu, 21 Jun 2012 15:02:43 -0700 Subject: [PATCH] Add tests to exercise the "pattern has N field(s), but" error patterns. --- .../compile-fail/alt-pattern-field-mismatch-2.rs | 16 ++++++++++++++++ .../compile-fail/alt-pattern-field-mismatch.rs | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/test/compile-fail/alt-pattern-field-mismatch-2.rs create mode 100644 src/test/compile-fail/alt-pattern-field-mismatch.rs diff --git a/src/test/compile-fail/alt-pattern-field-mismatch-2.rs b/src/test/compile-fail/alt-pattern-field-mismatch-2.rs new file mode 100644 index 00000000000..75e0763e4a6 --- /dev/null +++ b/src/test/compile-fail/alt-pattern-field-mismatch-2.rs @@ -0,0 +1,16 @@ +fn main() { + enum color { + rgb(uint, uint, uint), + cmyk(uint, uint, uint, uint), + no_color, + } + + fn foo(c: color) { + alt c { + rgb(_, _, _) { } + cmyk(_, _, _, _) { } + no_color(_) { } + //!^ ERROR this pattern has 1 field, but the corresponding variant has no fields + } + } +} diff --git a/src/test/compile-fail/alt-pattern-field-mismatch.rs b/src/test/compile-fail/alt-pattern-field-mismatch.rs new file mode 100644 index 00000000000..086267a85b3 --- /dev/null +++ b/src/test/compile-fail/alt-pattern-field-mismatch.rs @@ -0,0 +1,16 @@ +fn main() { + enum color { + rgb(uint, uint, uint), + cmyk(uint, uint, uint, uint), + no_color, + } + + fn foo(c: color) { + alt c { + rgb(_, _) { } + //!^ ERROR this pattern has 2 fields, but the corresponding variant has 3 fields + cmyk(_, _, _, _) { } + no_color { } + } + } +}