Skip to content

Commit

Permalink
ty: add tests for Type.is_invalid_named_type() (rust-lang#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-woelker committed Feb 7, 2017
1 parent f5394b3 commit c4eb4b2
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/ir/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ();
Expand Down

0 comments on commit c4eb4b2

Please sign in to comment.