@@ -44,6 +44,58 @@ describe('Field and Group Arithmetic Tests', () => {
44
44
expect ( two_power_four . equals ( two_times_eight ) ) . equal ( true ) ;
45
45
} ) ;
46
46
47
+ it ( 'Check boolean creation and serialization' , ( ) => {
48
+ const t = Boolean . one ( ) ;
49
+ const f = Boolean . zero ( ) ;
50
+
51
+ expect ( t . toString ( ) ) . equals ( "true" ) ;
52
+ expect ( f . toString ( ) ) . equals ( "false" ) ;
53
+
54
+ const tBytes = t . toBytesLe ( ) ;
55
+ const fBytes = f . toBytesLe ( ) ;
56
+
57
+ const tFromBytes = Boolean . fromBytesLe ( tBytes ) ;
58
+ const fFromBytes = Boolean . fromBytesLe ( fBytes ) ;
59
+
60
+ expect ( t . equals ( tFromBytes ) ) . equals ( true ) ;
61
+ expect ( f . equals ( fFromBytes ) ) . equals ( true ) ;
62
+
63
+ const tBits = t . toBitsLe ( ) ;
64
+ const fBits = f . toBitsLe ( ) ;
65
+
66
+ const tFromBits = Boolean . fromBitsLe ( tBits ) ;
67
+ const fFromBits = Boolean . fromBitsLe ( fBits ) ;
68
+
69
+ expect ( t . equals ( tFromBits ) ) . equals ( true ) ;
70
+ expect ( f . equals ( fFromBits ) ) . equals ( true ) ;
71
+ } ) ;
72
+
73
+ it ( 'Check boolean logical operations' , ( ) => {
74
+ const t = Boolean . one ( ) ;
75
+ const f = Boolean . zero ( ) ;
76
+
77
+ expect ( t . not ( ) . toString ( ) ) . equals ( "false" ) ;
78
+ expect ( f . not ( ) . toString ( ) ) . equals ( "true" ) ;
79
+
80
+ expect ( t . and ( t ) . toString ( ) ) . equals ( "true" ) ;
81
+ expect ( t . and ( f ) . toString ( ) ) . equals ( "false" ) ;
82
+ expect ( f . and ( f ) . toString ( ) ) . equals ( "false" ) ;
83
+
84
+ expect ( t . or ( t ) . toString ( ) ) . equals ( "true" ) ;
85
+ expect ( t . or ( f ) . toString ( ) ) . equals ( "true" ) ;
86
+ expect ( f . or ( f ) . toString ( ) ) . equals ( "false" ) ;
87
+
88
+ expect ( t . xor ( t ) . toString ( ) ) . equals ( "false" ) ;
89
+ expect ( t . xor ( f ) . toString ( ) ) . equals ( "true" ) ;
90
+ expect ( f . xor ( f ) . toString ( ) ) . equals ( "false" ) ;
91
+
92
+ expect ( t . nand ( t ) . toString ( ) ) . equals ( "false" ) ;
93
+ expect ( t . nand ( f ) . toString ( ) ) . equals ( "true" ) ;
94
+
95
+ expect ( f . nor ( f ) . toString ( ) ) . equals ( "true" ) ;
96
+ expect ( t . nor ( f ) . toString ( ) ) . equals ( "false" ) ;
97
+ } ) ;
98
+
47
99
it ( 'Check scalar field arithmetic' , ( ) => {
48
100
// Create the 2 scalar element.
49
101
const a = Scalar . fromString ( "2scalar" ) ;
0 commit comments