File tree Expand file tree Collapse file tree 2 files changed +84
-0
lines changed Expand file tree Collapse file tree 2 files changed +84
-0
lines changed Original file line number Diff line number Diff line change 1010
1111use std:: any:: Any ;
1212use std:: sync:: { Arc , Weak } ;
13+ use std:: cell:: RefCell ;
14+ use std:: cmp:: PartialEq ;
1315
1416#[ test]
1517fn uninhabited ( ) {
@@ -53,3 +55,43 @@ fn trait_object() {
5355 b = b. clone ( ) ;
5456 assert ! ( b. upgrade( ) . is_none( ) ) ;
5557}
58+
59+ #[ test]
60+ fn float_nan_ne ( ) {
61+ let x = Arc :: new ( std:: f32:: NAN ) ;
62+ assert ! ( x != x) ;
63+ assert ! ( !( x == x) ) ;
64+ }
65+
66+ #[ test]
67+ fn partial_eq ( ) {
68+ struct TestPEq ( RefCell < usize > ) ;
69+ impl PartialEq for TestPEq {
70+ fn eq ( & self , other : & TestPEq ) -> bool {
71+ * self . 0 . borrow_mut ( ) += 1 ;
72+ * other. 0 . borrow_mut ( ) += 1 ;
73+ true
74+ }
75+ }
76+ let x = Arc :: new ( TestPEq ( RefCell :: new ( 0 ) ) ) ;
77+ assert ! ( x == x) ;
78+ assert ! ( !( x != x) ) ;
79+ assert_eq ! ( * x. 0 . borrow( ) , 4 ) ;
80+ }
81+
82+ #[ test]
83+ fn eq ( ) {
84+ #[ derive( Eq ) ]
85+ struct TestEq ( RefCell < usize > ) ;
86+ impl PartialEq for TestEq {
87+ fn eq ( & self , other : & TestEq ) -> bool {
88+ * self . 0 . borrow_mut ( ) += 1 ;
89+ * other. 0 . borrow_mut ( ) += 1 ;
90+ true
91+ }
92+ }
93+ let x = Arc :: new ( TestEq ( RefCell :: new ( 0 ) ) ) ;
94+ assert ! ( x == x) ;
95+ assert ! ( !( x != x) ) ;
96+ assert_eq ! ( * x. 0 . borrow( ) , 0 ) ;
97+ }
Original file line number Diff line number Diff line change 1010
1111use std:: any:: Any ;
1212use std:: rc:: { Rc , Weak } ;
13+ use std:: cell:: RefCell ;
14+ use std:: cmp:: PartialEq ;
1315
1416#[ test]
1517fn uninhabited ( ) {
@@ -53,3 +55,43 @@ fn trait_object() {
5355 b = b. clone ( ) ;
5456 assert ! ( b. upgrade( ) . is_none( ) ) ;
5557}
58+
59+ #[ test]
60+ fn float_nan_ne ( ) {
61+ let x = Rc :: new ( std:: f32:: NAN ) ;
62+ assert ! ( x != x) ;
63+ assert ! ( !( x == x) ) ;
64+ }
65+
66+ #[ test]
67+ fn partial_eq ( ) {
68+ struct TestPEq ( RefCell < usize > ) ;
69+ impl PartialEq for TestPEq {
70+ fn eq ( & self , other : & TestPEq ) -> bool {
71+ * self . 0 . borrow_mut ( ) += 1 ;
72+ * other. 0 . borrow_mut ( ) += 1 ;
73+ true
74+ }
75+ }
76+ let x = Rc :: new ( TestPEq ( RefCell :: new ( 0 ) ) ) ;
77+ assert ! ( x == x) ;
78+ assert ! ( !( x != x) ) ;
79+ assert_eq ! ( * x. 0 . borrow( ) , 4 ) ;
80+ }
81+
82+ #[ test]
83+ fn eq ( ) {
84+ #[ derive( Eq ) ]
85+ struct TestEq ( RefCell < usize > ) ;
86+ impl PartialEq for TestEq {
87+ fn eq ( & self , other : & TestEq ) -> bool {
88+ * self . 0 . borrow_mut ( ) += 1 ;
89+ * other. 0 . borrow_mut ( ) += 1 ;
90+ true
91+ }
92+ }
93+ let x = Rc :: new ( TestEq ( RefCell :: new ( 0 ) ) ) ;
94+ assert ! ( x == x) ;
95+ assert ! ( !( x != x) ) ;
96+ assert_eq ! ( * x. 0 . borrow( ) , 0 ) ;
97+ }
You can’t perform that action at this time.
0 commit comments