@@ -122,11 +122,13 @@ class CircuitTestFixture {
122
122
if ( totbits <= 6 ) return this . testFunComplete ( fun , opts ) ;
123
123
else return this . testFunRandomized ( fun , opts ) ;
124
124
}
125
- testJSON ( ) {
125
+ testJSON ( json ) {
126
126
test ( "serialization test" , async ( ) => {
127
127
let json1 = this . circuit . toJSON ( ) ;
128
128
// Make sure the object can be serialized as JSON
129
129
let jsonstr1 = JSON . stringify ( json1 ) ;
130
+ if ( json )
131
+ expect ( json1 ) . toMatchObject ( json ) ;
130
132
// Test round trip
131
133
let circuit2 = new HeadlessCircuit ( JSON . parse ( jsonstr1 ) ) ;
132
134
let json2 = circuit2 . toJSON ( ) ;
@@ -743,6 +745,40 @@ describe('$fsm', () => {
743
745
} ) ;
744
746
} ) ;
745
747
748
+ describe ( 'order' , ( ) => {
749
+ // A circuit with order parameters on the ports
750
+ const circuit = {
751
+ subcircuits : {
752
+ sub_mod : {
753
+ devices : {
754
+ dev0 : { type : "Input" , net : "in1" , order : 0 , bits : 1 } ,
755
+ dev1 : { type : "Input" , net : "in2" , order : 1 , bits : 1 } ,
756
+ dev2 : { type : "Output" , net : "out1" , order : 2 , bits : 1 } ,
757
+ dev3 : { type : "Output" , net : "out2" , order : 3 , bits : 1 }
758
+ } ,
759
+ connectors : [ ]
760
+ }
761
+ } ,
762
+ devices : {
763
+ dev0 : { type : "Button" , net : "in1" , order : 0 , bits : 1 , label : "in1" } ,
764
+ dev1 : { type : "Button" , net : "in2" , order : 1 , bits : 1 , label : "in2" } ,
765
+ dev2 : { type : "Lamp" , net : "out1" , order : 2 , bits : 1 , label : "out1" } ,
766
+ dev3 : { type : "Lamp" , net : "out2" , order : 3 , bits : 1 , label : "out2" } ,
767
+ dev4 : { label : "m" , type : "Subcircuit" , celltype : "sub_mod" }
768
+ } ,
769
+ connectors : [
770
+ { to : { id : "dev4" , port : "in1" } , from : { id : "dev0" , port : "out" } , name : "in1" } ,
771
+ { to : { id : "dev4" , port : "in2" } , from : { id : "dev1" , port : "out" } , name : "in2" } ,
772
+ { to : { id : "dev2" , port : "in" } , from : { id : "dev4" , port : "out1" } , name : "out1" } ,
773
+ { to : { id : "dev3" , port : "in" } , from : { id : "dev4" , port : "out2" } , name : "out2" }
774
+ ]
775
+ } ;
776
+ const inlist = [ { name : 'in1' , bits : 1 } , { name : 'in2' , bits : 1 } ] ;
777
+ const outlist = [ { name : 'out1' , bits : 1 } , { name : 'out2' , bits : 1 } ] ;
778
+ new CircuitTestFixture ( circuit , inlist , outlist , engine )
779
+ . testJSON ( circuit ) ;
780
+ } ) ;
781
+
746
782
} ) ;
747
783
748
784
// TODO: tests for public circuit interface
0 commit comments