summaryrefslogtreecommitdiff
path: root/lib/bio/test/bio-endianrd.myr
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bio/test/bio-endianrd.myr')
-rw-r--r--lib/bio/test/bio-endianrd.myr29
1 files changed, 11 insertions, 18 deletions
diff --git a/lib/bio/test/bio-endianrd.myr b/lib/bio/test/bio-endianrd.myr
index e445459..8296c75 100644
--- a/lib/bio/test/bio-endianrd.myr
+++ b/lib/bio/test/bio-endianrd.myr
@@ -1,13 +1,6 @@
use std
use bio
-generic try = {opt : bio.status(@a::(integral,numeric))-> @a::(integral,numeric)
- match opt
- | `bio.Ok val: -> val
- | _: std.fatal("read failed")
- ;;
-}
-
const main = {
var b : byte
var w : uint16
@@ -23,31 +16,31 @@ const main = {
/* byte */
b = 0xaa
- var r = try(bio.getle8(f))
+ var r = std.try(bio.getle8(f))
std.assert(r == b, "le byte broken: {x}\n", r)
- std.assert(try(bio.getbe8(f)) == b, "be byte broken\n")
+ std.assert(std.try(bio.getbe8(f)) == b, "be byte broken\n")
/* word */
w = 0xaabb
- std.assert(try(bio.getle16(f)) == w, "le word broken\n")
- std.assert(try(bio.getbe16(f)) == w, "be word broken\n")
+ std.assert(std.try(bio.getle16(f)) == w, "le word broken\n")
+ std.assert(std.try(bio.getbe16(f)) == w, "be word broken\n")
/* long */
l = 0xaabbccdd
- std.assert(try(bio.getle32(f)) == l, "le long broken\n")
- std.assert(try(bio.getbe32(f)) == l, "be long broken\n")
+ std.assert(std.try(bio.getle32(f)) == l, "le long broken\n")
+ std.assert(std.try(bio.getbe32(f)) == l, "be long broken\n")
/* quad */
q = (0x11223344aabbccdd : uint64)
- std.assert(try(bio.getle64(f)) == q, "le quad broken\n")
- std.assert(try(bio.getbe64(f)) == q, "be quad broken\n")
+ std.assert(std.try(bio.getle64(f)) == q, "le quad broken\n")
+ std.assert(std.try(bio.getbe64(f)) == q, "be quad broken\n")
/* end of file */
match bio.getle64(f)
- | `bio.Eof:
- | `bio.Err _:
+ | `std.Err `bio.Eof:
+ | `std.Err _:
std.die("error on reading file\n")
- | `bio.Ok v:
+ | `std.Ok v:
std.die("read past end of file\n")
v = q /* shut up type inference */
;;