From: Ian Jackson Date: Sun, 11 Oct 2020 00:14:10 +0000 (+0100) Subject: wip range tests X-Git-Tag: otter-0.2.0~691 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=8ecbc860206bde0b42cf33d838fa4792bcf2399d;p=otter.git wip range tests Signed-off-by: Ian Jackson --- diff --git a/templates/bigfloat-tests.ts b/templates/bigfloat-tests.ts index d2c50cbd..68ee3a39 100644 --- a/templates/bigfloat-tests.ts +++ b/templates/bigfloat-tests.ts @@ -13,14 +13,6 @@ let x : any; let y : any let i : any -x = "!0000 ffff_ffff_fff0" as any; -y = "!0000 0000_0000_0040" as any; -i = Bigfloats.iter_upto(x, y, 4); - -assert_eq(i(), "+0000 0000_0000_0000"); -assert_eq(i(), "+0000 0000_0000_0010"); -assert_eq(i(), "+0000 0000_0000_0020"); -assert_eq(i(), "+0000 0000_0000_0030"); x = "!0000 ffff_ffff_fffe" as any; y = "!0000 0000_0000_0001" as any; diff --git a/zcoord/zcoord.rs b/zcoord/zcoord.rs index 5c8f1b3b..d88a6010 100644 --- a/zcoord/zcoord.rs +++ b/zcoord/zcoord.rs @@ -249,7 +249,7 @@ impl Mutable { } #[throws(RangeBackwards)] - pub fn range(&self, other: &Mutable, count: u32) -> RangeIterator { + pub fn range_upto(&self, other: &Mutable, count: u32) -> RangeIterator { Mutable::range_core(self, other, count)?.take(count as usize) } } @@ -613,4 +613,16 @@ mod test { .tinc("vvvvvvvvvv_vvvvvvvvvv_vvvvv01234_0000000000_0001000000") ; } + + #[test] + fn range(){ + let x = bf("vvvvvvvvv0").clone_mut(); + let y = bf("0000000040").clone_mut(); + let mut i = x.range_upto(&y, 4).unwrap(); + assert_eq!(i.next().unwrap().to_string(), "0000000000"); + assert_eq!(i.next().unwrap().to_string(), "0000000010"); + assert_eq!(i.next().unwrap().to_string(), "0000000020"); + assert_eq!(i.next().unwrap().to_string(), "0000000030"); + assert_eq!(i.next(), None); + } }