ref: ce93c2af0b4aeb2c40a05f2b45c1397b7a2ced23
parent: b24a5a737f897466dbf6ff9b3684e9e4d657e658
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Sep 11 19:50:09 EDT 2016
Enable and update the bio tests.
--- a/lib/bio/bld.sub
+++ b/lib/bio/bld.sub
@@ -7,3 +7,7 @@
lib ../std:std
lib ../sys:sys
;;
+
+sub =
+ test
+;;
--- a/lib/bio/test/bio-delim.myr
+++ b/lib/bio/test/bio-delim.myr
@@ -67,16 +67,24 @@
const readln = {f
match bio.readln(f)
- | `std.Some d: -> d
- | `std.None: std.put("eof\n")
- -> [][:]
+ | `bio.Ok d: -> d
+ | `bio.Eof:
+ std.put("eof\n")
+ -> [][:]
+ | `bio.Err e:
+ std.put("err\n")
+ -> [][:]
;;
}
const readto = {f, delim
match bio.readto(f, delim)
- | `std.Some d: -> d
- | `std.None: std.put("eof\n")
- -> [][:]
+ | `bio.Ok d: -> d
+ | `bio.Eof:
+ std.put("eof\n")
+ -> [][:]
+ | `bio.Err e:
+ std.put("err\n")
+ -> [][:]
;;
}
--- a/lib/bio/test/bio-endianrd.myr
+++ b/lib/bio/test/bio-endianrd.myr
@@ -1,12 +1,13 @@
use std
use bio
-generic try = {opt : std.option(@a::(integral,numeric))-> @a::(integral,numeric)
+generic try = {opt : bio.status(@a::(integral,numeric))-> @a::(integral,numeric)
match opt
- | `std.Some val: -> val
- | `std.None: std.fatal("read failed")
+ | `bio.Ok val: -> val
+ | _: std.fatal("read failed")
;;
}
+
const main = {
var b : byte
var w : uint16
@@ -21,13 +22,10 @@
;;
/* byte */
- /*
- /* FIXME: compiler bug. multiplication on byte
- values is currently broken. */
b = 0xaa
- std.assert(try(bio.getle8(f)) == b, "le byte broken\n")
+ var r = 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")
- */
/* word */
w = 0xaabb
@@ -46,8 +44,10 @@
/* end of file */
match bio.getle64(f)
- | `std.None:
- | `std.Some v:
+ | `bio.Eof:
+ | `bio.Err _:
+ std.die("error on reading file\n")
+ | `bio.Ok v:
std.die("read past end of file\n")
v = q /* shut up type inference */
;;
--- a/lib/bio/test/bio-endianwr.myr
+++ b/lib/bio/test/bio-endianwr.myr
@@ -8,19 +8,15 @@
var q : uint64
var f
- match bio.create("tmpout/test-endianwr", bio.Wr, 0o644)
+ match bio.create("data/out-endianwr", bio.Wr, 0o644)
| `std.Ok bio: f = bio
| `std.Err m: std.fatal("Unable to open data file: {}\n", m)
;;
/* byte */
- /*
- /* FIXME: compiler bug. multiplication on byte
- values is currently broken. */
b = 0xaa
- bio.putle(f, b)
- bio.putbe(f, b)
- */
+ bio.putle8(f, b)
+ bio.putbe8(f, b)
/* word */
w = 0xaabb
--- a/lib/bio/test/bio-peek.myr
+++ b/lib/bio/test/bio-peek.myr
@@ -28,18 +28,24 @@
const peekc = {f
match bio.peekc(f)
- | `std.Some c: -> c
- | `std.None:
+ | `bio.Ok c: -> c
+ | `bio.Eof:
std.put("eof")
-> -1
+ | `bio.Err e:
+ std.fatal("error reading\n")
+ -> -1
;;
}
const peekb = {f
match bio.peekb(f)
- | `std.Some b: -> b
- | `std.None:
+ | `bio.Ok b: -> b
+ | `bio.Eof:
std.put("eof")
+ -> -1
+ | `bio.Err e:
+ std.fatal("error reading\n")
-> -1
;;
}
--- a/lib/bio/test/bio-read.myr
+++ b/lib/bio/test/bio-read.myr
@@ -40,10 +40,13 @@
const r = {f, buf
match bio.read(f, buf)
- | `std.Some b:
+ | `bio.Ok b:
-> b
- | `std.None:
+ | `bio.Eof:
std.put("eof\n")
+ -> ""
+ | `bio.Err e:
+ std.put("err\n")
-> ""
;;
}
--- a/lib/bio/test/data/bio-endianwr-expected
+++ b/lib/bio/test/data/bio-endianwr-expected
@@ -1,1 +1,1 @@
-�����̻������̻�D3""3D���
\ No newline at end of file
+�������̻������̻�D3""3D���
\ No newline at end of file