@@ -37,8 +37,6 @@ use self::UnpackedAtom::{Dynamic, Inline, Static};
3737#[ cfg( feature = "log-events" ) ]
3838use event:: Event ;
3939
40- include ! ( concat!( env!( "OUT_DIR" ) , "/static_atom_set.rs" ) ) ;
41-
4240#[ cfg( not( feature = "log-events" ) ) ]
4341macro_rules! log ( ( $e: expr) => ( ( ) ) ) ;
4442
@@ -199,7 +197,7 @@ impl StaticAtomSet for EmptyStaticAtomSet {
199197pub type DefaultAtom = Atom < EmptyStaticAtomSet > ;
200198
201199pub struct Atom < Static : StaticAtomSet > {
202- /// This field is public so that the `atom!()` macro can use it.
200+ /// This field is public so that the `atom!()` macros can use it.
203201 /// You should not otherwise access this field.
204202 #[ doc( hidden) ]
205203 pub unsafe_data : u64 ,
@@ -234,7 +232,7 @@ impl<Static: StaticAtomSet> Atom<Static> {
234232
235233impl < Static : StaticAtomSet > Default for Atom < Static > {
236234 fn default ( ) -> Self {
237- atom ! ( "" )
235+ Self :: from ( "" )
238236 }
239237}
240238
@@ -581,26 +579,17 @@ fn copy_memory(src: &[u8], dst: &mut [u8]) {
581579 }
582580}
583581
584- #[ cfg( all( test, feature = "unstable" ) ) ]
585- #[ path = "bench.rs" ]
586- mod bench;
587-
588582#[ cfg( test) ]
583+ #[ macro_use]
589584mod tests {
590585 use std:: mem;
591586 use std:: thread;
592- use super :: Atom as GenericAtom ;
593- use super :: { StaticAtomSet , StringCacheEntry , STATIC_ATOM_SET , PhfStrSet } ;
587+ use super :: { StaticAtomSet , StringCacheEntry } ;
594588 use super :: UnpackedAtom :: { Dynamic , Inline , Static } ;
595589 use shared:: ENTRY_ALIGNMENT ;
596590
597- pub type Atom = GenericAtom < DefaultStatic > ;
598- pub struct DefaultStatic ;
599- impl StaticAtomSet for DefaultStatic {
600- fn get ( ) -> & ' static PhfStrSet {
601- & STATIC_ATOM_SET
602- }
603- }
591+ include ! ( concat!( env!( "OUT_DIR" ) , "/test_atom.rs" ) ) ;
592+ pub type Atom = TestAtom ;
604593
605594 #[ test]
606595 fn test_as_slice ( ) {
@@ -741,17 +730,17 @@ mod tests {
741730 assert_eq_fmt ! ( "0x{:016X}" , x. unsafe_data, Atom :: from( s) . unsafe_data) ;
742731 assert_eq ! ( 0x2 , x. unsafe_data & 0xFFFF_FFFF ) ;
743732 // The index is unspecified by phf.
744- assert ! ( ( x. unsafe_data >> 32 ) <= DefaultStatic :: get( ) . atoms. len( ) as u64 ) ;
733+ assert ! ( ( x. unsafe_data >> 32 ) <= TestAtomStaticSet :: get( ) . atoms. len( ) as u64 ) ;
745734 }
746735
747736 // This test is here to make sure we don't change atom representation
748737 // by accident. It may need adjusting if there are changes to the
749738 // static atom table, the tag values, etc.
750739
751740 // Static atoms
752- check_static ( "a" , atom ! ( "a" ) ) ;
753- check_static ( "address" , atom ! ( "address" ) ) ;
754- check_static ( "area" , atom ! ( "area" ) ) ;
741+ check_static ( "a" , test_atom ! ( "a" ) ) ;
742+ check_static ( "address" , test_atom ! ( "address" ) ) ;
743+ check_static ( "area" , test_atom ! ( "area" ) ) ;
755744
756745 // Inline atoms
757746 check ( "e" , 0x0000_0000_0000_6511 ) ;
@@ -790,27 +779,27 @@ mod tests {
790779
791780 #[ test]
792781 fn atom_macro ( ) {
793- assert_eq ! ( atom !( "body" ) , Atom :: from( "body" ) ) ;
794- assert_eq ! ( atom !( "font-weight" ) , Atom :: from( "font-weight" ) ) ;
782+ assert_eq ! ( test_atom !( "body" ) , Atom :: from( "body" ) ) ;
783+ assert_eq ! ( test_atom !( "font-weight" ) , Atom :: from( "font-weight" ) ) ;
795784 }
796785
797786 #[ test]
798787 fn match_atom ( ) {
799788 assert_eq ! ( 2 , match Atom :: from( "head" ) {
800- atom !( "br" ) => 1 ,
801- atom !( "html" ) | atom !( "head" ) => 2 ,
789+ test_atom !( "br" ) => 1 ,
790+ test_atom !( "html" ) | test_atom !( "head" ) => 2 ,
802791 _ => 3 ,
803792 } ) ;
804793
805794 assert_eq ! ( 3 , match Atom :: from( "body" ) {
806- atom !( "br" ) => 1 ,
807- atom !( "html" ) | atom !( "head" ) => 2 ,
795+ test_atom !( "br" ) => 1 ,
796+ test_atom !( "html" ) | test_atom !( "head" ) => 2 ,
808797 _ => 3 ,
809798 } ) ;
810799
811800 assert_eq ! ( 3 , match Atom :: from( "zzzzzz" ) {
812- atom !( "br" ) => 1 ,
813- atom !( "html" ) | atom !( "head" ) => 2 ,
801+ test_atom !( "br" ) => 1 ,
802+ test_atom !( "html" ) | test_atom !( "head" ) => 2 ,
814803 _ => 3 ,
815804 } ) ;
816805 }
@@ -869,3 +858,7 @@ mod tests {
869858 assert ! ( Atom :: from( "camembert" . to_owned( ) ) == Atom :: from( "camembert" ) ) ;
870859 }
871860}
861+
862+ #[ cfg( all( test, feature = "unstable" ) ) ]
863+ #[ path = "bench.rs" ]
864+ mod bench;
0 commit comments