@@ -37,8 +37,6 @@ use self::UnpackedAtom::{Dynamic, Inline, Static};
37
37
#[ cfg( feature = "log-events" ) ]
38
38
use event:: Event ;
39
39
40
- include ! ( concat!( env!( "OUT_DIR" ) , "/static_atom_set.rs" ) ) ;
41
-
42
40
#[ cfg( not( feature = "log-events" ) ) ]
43
41
macro_rules! log ( ( $e: expr) => ( ( ) ) ) ;
44
42
@@ -199,7 +197,7 @@ impl StaticAtomSet for EmptyStaticAtomSet {
199
197
pub type DefaultAtom = Atom < EmptyStaticAtomSet > ;
200
198
201
199
pub 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.
203
201
/// You should not otherwise access this field.
204
202
#[ doc( hidden) ]
205
203
pub unsafe_data : u64 ,
@@ -234,7 +232,7 @@ impl<Static: StaticAtomSet> Atom<Static> {
234
232
235
233
impl < Static : StaticAtomSet > Default for Atom < Static > {
236
234
fn default ( ) -> Self {
237
- atom ! ( "" )
235
+ Self :: from ( "" )
238
236
}
239
237
}
240
238
@@ -581,26 +579,17 @@ fn copy_memory(src: &[u8], dst: &mut [u8]) {
581
579
}
582
580
}
583
581
584
- #[ cfg( all( test, feature = "unstable" ) ) ]
585
- #[ path = "bench.rs" ]
586
- mod bench;
587
-
588
582
#[ cfg( test) ]
583
+ #[ macro_use]
589
584
mod tests {
590
585
use std:: mem;
591
586
use std:: thread;
592
- use super :: Atom as GenericAtom ;
593
- use super :: { StaticAtomSet , StringCacheEntry , STATIC_ATOM_SET , PhfStrSet } ;
587
+ use super :: { StaticAtomSet , StringCacheEntry } ;
594
588
use super :: UnpackedAtom :: { Dynamic , Inline , Static } ;
595
589
use shared:: ENTRY_ALIGNMENT ;
596
590
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 ;
604
593
605
594
#[ test]
606
595
fn test_as_slice ( ) {
@@ -741,17 +730,17 @@ mod tests {
741
730
assert_eq_fmt ! ( "0x{:016X}" , x. unsafe_data, Atom :: from( s) . unsafe_data) ;
742
731
assert_eq ! ( 0x2 , x. unsafe_data & 0xFFFF_FFFF ) ;
743
732
// 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 ) ;
745
734
}
746
735
747
736
// This test is here to make sure we don't change atom representation
748
737
// by accident. It may need adjusting if there are changes to the
749
738
// static atom table, the tag values, etc.
750
739
751
740
// 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" ) ) ;
755
744
756
745
// Inline atoms
757
746
check ( "e" , 0x0000_0000_0000_6511 ) ;
@@ -789,27 +778,27 @@ mod tests {
789
778
790
779
#[ test]
791
780
fn atom_macro ( ) {
792
- assert_eq ! ( atom !( "body" ) , Atom :: from( "body" ) ) ;
793
- assert_eq ! ( atom !( "font-weight" ) , Atom :: from( "font-weight" ) ) ;
781
+ assert_eq ! ( test_atom !( "body" ) , Atom :: from( "body" ) ) ;
782
+ assert_eq ! ( test_atom !( "font-weight" ) , Atom :: from( "font-weight" ) ) ;
794
783
}
795
784
796
785
#[ test]
797
786
fn match_atom ( ) {
798
787
assert_eq ! ( 2 , match Atom :: from( "head" ) {
799
- atom !( "br" ) => 1 ,
800
- atom !( "html" ) | atom !( "head" ) => 2 ,
788
+ test_atom !( "br" ) => 1 ,
789
+ test_atom !( "html" ) | test_atom !( "head" ) => 2 ,
801
790
_ => 3 ,
802
791
} ) ;
803
792
804
793
assert_eq ! ( 3 , match Atom :: from( "body" ) {
805
- atom !( "br" ) => 1 ,
806
- atom !( "html" ) | atom !( "head" ) => 2 ,
794
+ test_atom !( "br" ) => 1 ,
795
+ test_atom !( "html" ) | test_atom !( "head" ) => 2 ,
807
796
_ => 3 ,
808
797
} ) ;
809
798
810
799
assert_eq ! ( 3 , match Atom :: from( "zzzzzz" ) {
811
- atom !( "br" ) => 1 ,
812
- atom !( "html" ) | atom !( "head" ) => 2 ,
800
+ test_atom !( "br" ) => 1 ,
801
+ test_atom !( "html" ) | test_atom !( "head" ) => 2 ,
813
802
_ => 3 ,
814
803
} ) ;
815
804
}
@@ -868,3 +857,7 @@ mod tests {
868
857
assert ! ( Atom :: from( "camembert" . to_owned( ) ) == Atom :: from( "camembert" ) ) ;
869
858
}
870
859
}
860
+
861
+ #[ cfg( all( test, feature = "unstable" ) ) ]
862
+ #[ path = "bench.rs" ]
863
+ mod bench;
0 commit comments