diff options
| author | Lindsey Kuper <lindsey@rockstargirl.org> | 2012-06-21 15:02:43 -0700 |
|---|---|---|
| committer | Lindsey Kuper <lindsey@rockstargirl.org> | 2012-06-21 16:19:04 -0700 |
| commit | 0fe9c0a9d11e64f556fcdee8296d7ae43c7fcd35 (patch) | |
| tree | 01931845ef7c2ef5769b21ca08725dc5fa9bfc4c | |
| parent | abfa8164cd9d64e95039019eb9b4c3fdec2685c5 (diff) | |
| download | rust-0fe9c0a9d11e64f556fcdee8296d7ae43c7fcd35.tar.gz rust-0fe9c0a9d11e64f556fcdee8296d7ae43c7fcd35.zip | |
Add tests to exercise the "pattern has N field(s), but" error patterns.
| -rw-r--r-- | src/test/compile-fail/alt-pattern-field-mismatch-2.rs | 16 | ||||
| -rw-r--r-- | src/test/compile-fail/alt-pattern-field-mismatch.rs | 16 |
2 files changed, 32 insertions, 0 deletions
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 { } + } + } +} |
