about summary refs log tree commit diff
path: root/compiler/rustc_span/src/symbol/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_span/src/symbol/tests.rs')
-rw-r--r--compiler/rustc_span/src/symbol/tests.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/compiler/rustc_span/src/symbol/tests.rs b/compiler/rustc_span/src/symbol/tests.rs
new file mode 100644
index 00000000000..47da03424b7
--- /dev/null
+++ b/compiler/rustc_span/src/symbol/tests.rs
@@ -0,0 +1,25 @@
+use super::*;
+
+use crate::{edition, SessionGlobals};
+
+#[test]
+fn interner_tests() {
+    let mut i: Interner = Interner::default();
+    // first one is zero:
+    assert_eq!(i.intern("dog"), Symbol::new(0));
+    // re-use gets the same entry:
+    assert_eq!(i.intern("dog"), Symbol::new(0));
+    // different string gets a different #:
+    assert_eq!(i.intern("cat"), Symbol::new(1));
+    assert_eq!(i.intern("cat"), Symbol::new(1));
+    // dog is still at zero
+    assert_eq!(i.intern("dog"), Symbol::new(0));
+}
+
+#[test]
+fn without_first_quote_test() {
+    SESSION_GLOBALS.set(&SessionGlobals::new(edition::DEFAULT_EDITION), || {
+        let i = Ident::from_str("'break");
+        assert_eq!(i.without_first_quote().name, kw::Break);
+    });
+}