diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-02-07 18:41:10 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-07 18:41:10 -0800 |
commit | cedadf9c48099d831b898d5c90e2868f4d11743f (patch) | |
tree | b24beefcf7e7f7e82a7636793f66efb4d947cd95 | |
parent | 16cc5bfe1891e762c9e70fdd267b0e46bdb4330b (diff) | |
parent | c4eb4b2e4ed933d00586a227915abae37acf8643 (diff) |
Auto merge of #490 - manuel-woelker:master, r=fitzgen
ty: add tests for Type.is_invalid_named_type() (#460)
I didn't add an extra test module, since I couldn't find any precedents in the project.
Feedback welcome!
-rw-r--r-- | src/ir/ty.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/ir/ty.rs b/src/ir/ty.rs index 5903430c..f1e43983 100644 --- a/src/ir/ty.rs +++ b/src/ir/ty.rs @@ -392,6 +392,51 @@ impl Type { } } } +#[test] +fn is_invalid_named_type_valid() { + let ty = Type::new(Some("foo".into()), None, TypeKind::Named, false); + assert!(!ty.is_invalid_named_type()) +} + +#[test] +fn is_invalid_named_type_valid_underscore_and_numbers() { + let ty = + Type::new(Some("_foo123456789_".into()), None, TypeKind::Named, false); + assert!(!ty.is_invalid_named_type()) +} + +#[test] +fn is_invalid_named_type_valid_unnamed_kind() { + let ty = Type::new(Some("foo".into()), None, TypeKind::Void, false); + assert!(!ty.is_invalid_named_type()) +} + +#[test] +fn is_invalid_named_type_invalid_start() { + let ty = Type::new(Some("1foo".into()), None, TypeKind::Named, false); + assert!(ty.is_invalid_named_type()) +} + +#[test] +fn is_invalid_named_type_invalid_remaing() { + let ty = Type::new(Some("foo-".into()), None, TypeKind::Named, false); + assert!(ty.is_invalid_named_type()) +} + +#[test] +#[should_panic] +fn is_invalid_named_type_unnamed() { + let ty = Type::new(None, None, TypeKind::Named, false); + assert!(ty.is_invalid_named_type()) +} + +#[test] +#[should_panic] +fn is_invalid_named_type_empty_name() { + let ty = Type::new(Some("".into()), None, TypeKind::Named, false); + assert!(ty.is_invalid_named_type()) +} + impl CanDeriveDebug for Type { type Extra = (); |