Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tjjfvi committed Mar 4, 2024
1 parent 335e40a commit 722946f
Show file tree
Hide file tree
Showing 32 changed files with 79 additions and 80 deletions.
4 changes: 2 additions & 2 deletions src/host/readback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ impl<'a> ReadbackState<'a> {
/// `vars` map.
fn read_port(&mut self, port: Port, wire: Option<Wire>) -> Tree {
match port.tag() {
Tag::Var => {
Tag::Var | Tag::Red => {
// todo: resolve redirects
let key = wire.unwrap().addr().min(port.addr());
Tree::Var {
nam: create_var(match self.vars.entry(key) {
Expand All @@ -52,7 +53,6 @@ impl<'a> ReadbackState<'a> {
}),
}
}
Tag::Red => self.read_wire(port.wire()),
Tag::Ref if port == Port::ERA => Tree::Era,
Tag::Ref => Tree::Ref { nam: self.host.back[&port.addr()].clone() },
Tag::Num => Tree::Num { val: port.num() },
Expand Down
5 changes: 2 additions & 3 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,15 @@ fn test_cli_errors() {
fn test_apply_tree() {
use hvmc::run;
fn eval_with_args(fun: &str, args: &[&str]) -> Net {
let area = run::Heap::new_words(1 << 10);
let area = run::Heap::new_words(16);

let mut fun: Net = fun.parse().unwrap();
for arg in args {
let arg: Tree = arg.parse().unwrap();
fun.apply_tree(arg)
}
// TODO: When feature/sc-472/argument-passing, use encode_net instead.
let host = Host::default();

let host = Host::default();
let mut rnet = run::Net::<run::Strict>::new(&area);
let root_port = run::Trg::port(run::Port::new_var(rnet.root.addr()));
host.encode_net(&mut rnet, root_port, &fun);
Expand Down
24 changes: 12 additions & 12 deletions tests/lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ fn test_list_got() {
rwts_list.push(rwts.total())
}

assert_debug_snapshot!(rwts_list[0], @"579");
assert_debug_snapshot!(rwts_list[1], @"601");
assert_debug_snapshot!(rwts_list[2], @"645");
assert_debug_snapshot!(rwts_list[3], @"733");
assert_debug_snapshot!(rwts_list[4], @"909");
assert_debug_snapshot!(rwts_list[5], @"1261");
assert_debug_snapshot!(rwts_list[0], @"594");
assert_debug_snapshot!(rwts_list[1], @"623");
assert_debug_snapshot!(rwts_list[2], @"681");
assert_debug_snapshot!(rwts_list[3], @"797");
assert_debug_snapshot!(rwts_list[4], @"1029");
assert_debug_snapshot!(rwts_list[5], @"1493");

// Tests the linearity of the function
let delta = rwts_list[1] - rwts_list[0];
Expand All @@ -61,12 +61,12 @@ fn test_list_put() {
rwts_list.push(rwts.total())
}

assert_debug_snapshot!(rwts_list[0], @"570");
assert_debug_snapshot!(rwts_list[1], @"593");
assert_debug_snapshot!(rwts_list[2], @"639");
assert_debug_snapshot!(rwts_list[3], @"731");
assert_debug_snapshot!(rwts_list[4], @"915");
assert_debug_snapshot!(rwts_list[5], @"1283");
assert_debug_snapshot!(rwts_list[0], @"585");
assert_debug_snapshot!(rwts_list[1], @"615");
assert_debug_snapshot!(rwts_list[2], @"675");
assert_debug_snapshot!(rwts_list[3], @"795");
assert_debug_snapshot!(rwts_list[4], @"1035");
assert_debug_snapshot!(rwts_list[5], @"1515");

//Tests the linearity of the function
let delta = rwts_list[1] - rwts_list[0];
Expand Down
6 changes: 3 additions & 3 deletions tests/numeric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn test_add() {
let net = op_net(10, Op::Add, 2);
let (rwts, net) = normal(net, 16);
assert_snapshot!(Net::to_string(&net), @"#12");
assert_debug_snapshot!(rwts.total(), @"3");
assert_debug_snapshot!(rwts.total(), @"4");
}

#[test]
Expand Down Expand Up @@ -103,7 +103,7 @@ fn test_not() {
let net = op_net(0, Op::Not, 256);
let (rwts, net) = normal(net, 16);
assert_snapshot!(Net::to_string(&net), @"#1152921504606846975");
assert_debug_snapshot!(rwts.total(), @"3");
assert_debug_snapshot!(rwts.total(), @"4");
}

#[test]
Expand All @@ -125,5 +125,5 @@ fn test_div_by_0() {
let net = op_net(9, Op::Div, 0);
let (rwts, net) = normal(net, 16);
assert_snapshot!(Net::to_string(&net), @"#0");
assert_debug_snapshot!(rwts.total(), @"3");
assert_debug_snapshot!(rwts.total(), @"4");
}
4 changes: 2 additions & 2 deletions tests/snapshots/tests__run@alloc_big_tree.hvmc.snap

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tests/snapshots/tests__run@alloc_small_tree.hvmc.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ expression: output
input_file: tests/programs/alloc_small_tree.hvmc
---
(a (* a))
RWTS : 99
RWTS : 104
- ANNI : 43
- COMM : 13
- ERAS : 17
- DREF : 26
- DREF : 31
- OPER : 0
4 changes: 2 additions & 2 deletions tests/snapshots/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ expression: output
input_file: examples/arithmetic.hvmc
---
({3 </ a b> <% c d>} ({5 a c} [b d]))
RWTS : 7
RWTS : 18
- ANNI : 4
- COMM : 0
- ERAS : 0
- DREF : 3
- DREF : 14
- OPER : 0
4 changes: 2 additions & 2 deletions tests/snapshots/tests__run@chained_ops.hvmc.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ expression: output
input_file: tests/programs/chained_ops.hvmc
---
#7184190578800
RWTS : 47
RWTS : 48
- ANNI : 2
- COMM : 4
- ERAS : 0
- DREF : 1
- DREF : 2
- OPER : 40
4 changes: 2 additions & 2 deletions tests/snapshots/tests__run@church_encoding__church.hvmc.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ expression: output
input_file: examples/church_encoding/church.hvmc
---
({11 {7 (a {5 b c}) {9 (d a) ({5 c e} d)}} {3 (f e) {3 (g f) {3 (h g) {3 (i h) *}}}}} (i b))
RWTS : 37
RWTS : 65
- ANNI : 25
- COMM : 1
- ERAS : 0
- DREF : 11
- DREF : 39
- OPER : 0
4 changes: 2 additions & 2 deletions tests/snapshots/tests__run@church_exp.hvmc.snap
Original file line number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 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 a b} c} d} e} f} g} h} i} j} k} l} m} n} o} p} q} r} s} t} u} v} w} x} y} z} aa} ab} ac} ad} ae} af} ag} ah} ai} aj} ak} al} am} an} ao} ap} aq} ar} as} at} au} av} aw} ax} ay} az} ba} bb} bc} bd} be} bf} bg} bh} bi} bj} bk} bl} bm} bn} bo} bp} bq} br} bs} bt} bu} bv} bw} bx} by} bz} ca} cb} cc} cd} ce} cf} cg} ch} ci} cj} ck} cl} cm} cn} co} cp} cq} cr} cs} ct} cu} cv} cw} cx} cy} cz} da} db} dc} dd} de} df} dg} dh} di} dj} dk} dl} dm} dn} do} dp} dq} dr} ds} dt} du} dv} dw} dx} dy} dz} ea} eb} ec} ed} ee} ef} eg} eh} ei} ej} ek} el} em} en} eo} ep} eq} er} es} et} eu} ev} ew} ex} ey} ez} fa} fb} fc} fd} fe} ff} fg} fh} fi} fj} fk} fl} fm} fn} fo} fp} fq} fr} fs} ft} fu} fv} fw} fx} fy} fz} ga} gb} gc} gd} ge} gf} gg} gh} gi} gj} gk} gl} gm} gn} go} gp} gq} gr} gs} gt} gu} gv} gw} gx} gy} gz} ha} hb} hc} hd} he} hf} hg} hh} hi} hj} hk} hl} hm} hn} ho} hp} hq} hr} hs} ht} hu} hv} hw} hx} hy} hz} ia} ib} ic} id} ie} if} ig} ih} ii} ij} ik} il} im} in} io} ip} iq} ir} is} it} iu} iv} iw} ix} iy} iz} ja} jb} jc} jd} je} jf} jg} jh} ji} jj} jk} jl} jm} jn} jo} jp} jq} jr} js} jt} ju} jv} jw} jx} jy} jz} ka} kb} kc} kd} ke} kf} kg} kh} ki} kj} kk} kl} km} kn} ko} kp} kq} kr} ks} kt} ku} kv} kw} kx} ky} kz} la} lb} lc} ld} le} lf} lg} lh} li} lj} lk} ll} lm} ln} lo} lp} lq} lr} ls} lt} lu} lv} lw} lx} ly} lz} ma} mb} mc} md} me} mf} mg} mh} mi} mj} mk} ml} mm} mn} mo} mp} mq} mr} ms} mt} mu} mv} mw} mx} my) (my mz)} (mz na)} (na nb)} (nb nc)} (nc nd)} (nd ne)} (ne nf)} (nf ng)} (ng nh)} (nh ni)} (ni nj)} (nj nk)} (nk nl)} (nl nm)} (nm nn)} (nn no)} (no np)} (np nq)} (nq {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 mf mg} mh} mi} mj} mk} ml} mm} mn} mo} mp} mq} mr} ms} mt} mu} mv} mw} mx} {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 lm ln} lo} lp} lq} lr} ls} lt} lu} lv} lw} lx} ly} lz} ma} mb} mc} md} me} {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 kt ku} kv} kw} kx} ky} kz} la} lb} lc} ld} le} lf} lg} lh} li} lj} lk} ll} {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 ka kb} kc} kd} ke} kf} kg} kh} ki} kj} kk} kl} km} kn} ko} kp} kq} kr} ks} {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 jh ji} jj} jk} jl} jm} jn} jo} jp} jq} jr} js} jt} ju} jv} jw} jx} jy} jz} {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 io ip} iq} ir} is} it} iu} iv} iw} ix} iy} iz} ja} jb} jc} jd} je} jf} jg} {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 hv hw} hx} hy} hz} ia} ib} ic} id} ie} if} ig} ih} ii} ij} ik} il} im} in} {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 hc hd} he} hf} hg} hh} hi} hj} hk} hl} hm} hn} ho} hp} hq} hr} hs} ht} hu} {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 gj gk} gl} gm} gn} go} gp} gq} gr} gs} gt} gu} gv} gw} gx} gy} gz} ha} hb} {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 fq fr} fs} ft} fu} fv} fw} fx} fy} fz} ga} gb} gc} gd} ge} gf} gg} gh} gi} {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 ex ey} ez} fa} fb} fc} fd} fe} ff} fg} fh} fi} fj} fk} fl} fm} fn} fo} fp} {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 ee ef} eg} eh} ei} ej} ek} el} em} en} eo} ep} eq} er} es} et} eu} ev} ew} {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 dl dm} dn} do} dp} dq} dr} ds} dt} du} dv} dw} dx} dy} dz} ea} eb} ec} ed} {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 cs ct} cu} cv} cw} cx} cy} cz} da} db} dc} dd} de} df} dg} dh} di} dj} dk} {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 bz ca} cb} cc} cd} ce} cf} cg} ch} ci} cj} ck} cl} cm} cn} co} cp} cq} cr} {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 bg bh} bi} bj} bk} bl} bm} bn} bo} bp} bq} br} bs} bt} bu} bv} bw} bx} by} {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 an ao} ap} aq} ar} as} at} au} av} aw} ax} ay} az} ba} bb} bc} bd} be} bf} {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 u v} w} x} y} z} aa} ab} ac} ad} ae} af} ag} ah} ai} aj} ak} al} am} {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 {2 b c} d} e} f} g} h} i} j} k} l} m} n} o} p} q} r} s} t} nr}}}}}}}}}}}}}}}}}}})} (a nr))
RWTS : 803
RWTS : 1_948
- ANNI : 401
- COMM : 380
- ERAS : 0
- DREF : 22
- DREF : 1_167
- OPER : 0
4 changes: 2 additions & 2 deletions tests/snapshots/tests__run@church_mul.hvmc.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ expression: output
input_file: tests/programs/church_mul.hvmc
---
({3 (a {3 b {5 c {7 d {9 e {11 f {13 g {15 h {17 i {19 j {21 k {23 l {25 m {27 n {29 o {31 p {33 q {35 r {37 s {39 t u}}}}}}}}}}}}}}}}}}}) {5 (v a) {7 (w v) {9 (x w) {11 (y x) {13 (z y) {15 (aa z) {17 (ab aa) {19 (ac ab) {21 (ad ac) {23 (ae ad) {25 (af ae) {27 (ag af) {29 (ah ag) {31 (ai ah) {33 (aj ai) {35 (ak aj) {37 (al ak) {39 (am al) ({3 c {5 d {7 e {9 f {11 g {13 h {15 i {17 j {19 k {21 l {23 m {25 n {27 o {29 p {31 q {33 r {35 s {37 t {39 u an}}}}}}}}}}}}}}}}}}} am)}}}}}}}}}}}}}}}}}}} (an b))
RWTS : 48
RWTS : 167
- ANNI : 25
- COMM : 19
- ERAS : 0
- DREF : 4
- DREF : 123
- OPER : 0
4 changes: 2 additions & 2 deletions tests/snapshots/tests__run@dec_bits.hvmc.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ expression: output
input_file: tests/programs/dec_bits.hvmc
---
(* (* (a a)))
RWTS : 180_036
RWTS : 180_043
- ANNI : 98_190
- COMM : 11
- ERAS : 32_738
- DREF : 49_097
- DREF : 49_104
- OPER : 0
4 changes: 2 additions & 2 deletions tests/snapshots/tests__run@dec_bits_tree.hvmc.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ expression: output
input_file: tests/programs/dec_bits_tree.hvmc
---
(((((((* (* (a a))) (* (* (b b)))) ((* (* (c c))) (* (* (d d))))) (((* (* (e e))) (* (* (f f)))) ((* (* (g g))) (* (* (h h)))))) ((((* (* (i i))) (* (* (j j)))) ((* (* (k k))) (* (* (l l))))) (((* (* (m m))) (* (* (n n)))) ((* (* (o o))) (* (* (p p))))))) (((((* (* (q q))) (* (* (r r)))) ((* (* (s s))) (* (* (t t))))) (((* (* (u u))) (* (* (v v)))) ((* (* (w w))) (* (* (x x)))))) ((((* (* (y y))) (* (* (z z)))) ((* (* (aa aa))) (* (* (ab ab))))) (((* (* (ac ac))) (* (* (ad ad)))) ((* (* (ae ae))) (* (* (af af)))))))) ((((((* (* (ag ag))) (* (* (ah ah)))) ((* (* (ai ai))) (* (* (aj aj))))) (((* (* (ak ak))) (* (* (al al)))) ((* (* (am am))) (* (* (an an)))))) ((((* (* (ao ao))) (* (* (ap ap)))) ((* (* (aq aq))) (* (* (ar ar))))) (((* (* (as as))) (* (* (at at)))) ((* (* (au au))) (* (* (av av))))))) (((((* (* (aw aw))) (* (* (ax ax)))) ((* (* (ay ay))) (* (* (az az))))) (((* (* (ba ba))) (* (* (bb bb)))) ((* (* (bc bc))) (* (* (bd bd)))))) ((((* (* (be be))) (* (* (bf bf)))) ((* (* (bg bg))) (* (* (bh bh))))) (((* (* (bi bi))) (* (* (bj bj)))) ((* (* (bk bk))) (* (* (bl bl)))))))))
RWTS : 2_874_410
RWTS : 2_874_985
- ANNI : 1_567_101
- COMM : 872
- ERAS : 522_751
- DREF : 783_686
- DREF : 784_261
- OPER : 0
4 changes: 2 additions & 2 deletions tests/snapshots/tests__run@lambda_calculus__hoas.hvmc.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ expression: output
input_file: examples/lambda_calculus/hoas.hvmc
---
(((a (((* a) b) (* (* b)))) c) (* (* c)))
RWTS : 868
RWTS : 886
- ANNI : 484
- COMM : 11
- ERAS : 141
- DREF : 232
- DREF : 250
- OPER : 0
Loading

0 comments on commit 722946f

Please sign in to comment.