code wiki / (root) / nx_solid_column_union_gate_t365.nx

nx_solid_column_union_gate_t365.nx source

↩ module page · 27 lines · 3868 B

1import "nx_solid_column_union_candidate_t365.nx" 2import "nx_gate_verdict.nx" 3func main(argc:i64,argv:*i64)->i64{ 4 let g:*i64=gv_ctr();gv_head("Per-part solid union v1" as *u8) 5 let h:*i64=sys_mmap(64) as *i64;let c:*i64=sys_mmap(32) as *i64 6 let o:*NxBufOwned=sys_mmap(__size_of(NxBufOwned)) as *NxBufOwned;let e:*SfuFailure=sys_mmap(__size_of(SfuFailure)) as *SfuFailure;let v:*i64=sys_mmap(8) as *i64 7 h[0]=0;h[1]=10;h[2]=5;h[3]=15;c[0]=2;c[1]=2 8 var rc:i64=sfu_union_v1(h,4,c,2,32,o,e);gv_check("overlapping parts form one interval" as *u8,(rc==0&&o.len==16) as i64,g) 9 let a:*i64=o.buf as *i64;gv_check("overlap retains complete extent" as *u8,(a[0]==0&&a[1]==15) as i64,g) 10 sfu_column_value(a,2,7,100,v);gv_check("overlap interior stays inside rather than XOR hole" as *u8,(v[0]==-7) as i64,g);nx_bo_release(o) 11 h[2]=20;h[3]=30;rc=sfu_union_v1(h,4,c,2,32,o,e);gv_check("separated parts stay separate" as *u8,(rc==0&&o.len==32) as i64,g);sfu_column_value(o.buf as *i64,4,15,100,v);gv_check("gap stays outside" as *u8,(v[0]==5) as i64,g);nx_bo_release(o) 12 h[2]=10;h[3]=20;rc=sfu_union_v1(h,4,c,2,32,o,e);sfu_column_value(o.buf as *i64,2,10,100,v);gv_check("touching boundary is removed from union interior" as *u8,(rc==0&&o.len==16&&v[0]==-10) as i64,g);nx_bo_release(o) 13 h[2]=0;h[3]=10;rc=sfu_union_v1(h,4,c,2,32,o,e);gv_check("coincident solids preserve one solid" as *u8,(rc==0&&o.len==16) as i64,g);nx_bo_release(o) 14 c[0]=3;c[1]=1;rc=sfu_union_v1(h,4,c,2,32,o,e);gv_check("odd crossings refuse with exact part and count" as *u8,(rc==SFU_ODD&&e.part==0&&e.crossing==3&&o.cap==0) as i64,g) 15 c[0]=2;c[1]=2;h[1]=0;rc=sfu_union_v1(h,4,c,2,32,o,e);gv_check("duplicate unresolved crossings refuse" as *u8,(rc==SFU_ORDER&&o.cap==0) as i64,g) 16 h[1]=10;rc=sfu_union_v1(h,4,c,2,31,o,e);gv_check("caller resource budget refuses before allocation" as *u8,(rc==SFU_RESOURCE&&o.cap==0) as i64,g) 17 rc=sfu_union_v1(h,4,c,2,32,o,e);let keep:i64=o.buf as i64;rc=sfu_union_v1(h,4,c,2,32,o,e);gv_check("live result ownership preserved" as *u8,(rc==SFU_INVALID&&(o.buf as i64)==keep&&o.len==16) as i64,g);nx_bo_release(o) 18 h[0]=-10;h[1]=0;h[2]=5;h[3]=15;rc=sfu_union_v1(h,4,c,2,32,o,e);sfu_column_value(o.buf as *i64,4,-5,100,v);gv_check("caller negative coordinates retained" as *u8,(rc==0&&v[0]==-5) as i64,g);nx_bo_release(o) 19 c[0]=0;c[1]=0;rc=sfu_union_v1(h,0,c,2,0,o,e);sfu_column_value(h,0,0,37,v);gv_check("empty column remains outside with declared cap" as *u8,(rc==0&&o.cap==0&&v[0]==37) as i64,g) 20 h[0]=-SFU_COORD;h[1]=SFU_COORD;v[0]=123;rc=sfu_column_value(h,2,0,9223372036854775807,v);gv_check("signed coordinate domain subtraction remains exact" as *u8,(rc==0&&v[0]==-SFU_COORD) as i64,g) 21 v[0]=123;rc=sfu_column_value(h,2,SFU_COORD+1,100,v);gv_check("out of domain preserves previous value" as *u8,(rc==SFU_INVALID&&v[0]==123) as i64,g) 22 h[0]=10;h[1]=20;h[2]=-10;h[3]=0;c[0]=2;c[1]=2;rc=sfu_union_v1(h,4,c,2,32,o,e);if rc==0{let a:*i64=o.buf as *i64;gv_check("reverse interval order preserves both pairs without boundary read" as *u8,(o.len==32&&a[0]==-10&&a[1]==0&&a[2]==10&&a[3]==20) as i64,g)}else{gv_check("reverse interval order preserves both pairs without boundary read" as *u8,0,g)};nx_bo_release(o) 23 h[0]=20;h[1]=9;h[2]=10;h[3]=7;rc=nx_sort_pairs_first(h,2);gv_check("shared pair sort keeps adjacent payload attached" as *u8,(rc==0&&h[0]==10&&h[1]==7&&h[2]==20&&h[3]==9) as i64,g) 24 rc=nx_sort_pairs_first(h,0);gv_check("zero pair sort unchanged" as *u8,(rc==0&&h[0]==10) as i64,g);rc=nx_sort_pairs_first(h,1);gv_check("one pair sort unchanged" as *u8,(rc==0&&h[0]==10&&h[1]==7) as i64,g) 25 rc=nx_sort_pairs_first(h,9223372036854775807);gv_check("pair byte extent refusal preserves data" as *u8,(rc==-1&&h[0]==10&&h[1]==7) as i64,g) 26 return gv_verdict("solid_column_union" as *u8,g,"column intervals only; no mesh crossing or metric SDF qualification" as *u8) 27}