implement most of the missing functions for sic simulator
This commit is contained in:
parent
25c1c1eb6c
commit
24455d9eb8
6 changed files with 706 additions and 142 deletions
|
|
@ -1,4 +1,6 @@
|
|||
import gleeunit
|
||||
import sim/device
|
||||
import sim/memory
|
||||
|
||||
pub fn main() -> Nil {
|
||||
gleeunit.main()
|
||||
|
|
@ -11,3 +13,35 @@ pub fn hello_world_test() {
|
|||
|
||||
assert greeting == "Hello, Joe!"
|
||||
}
|
||||
|
||||
pub fn pad_test() {
|
||||
assert <<1, 2, 3, 0>> == memory.pad_to_length(<<1, 2, 3>>, 32)
|
||||
}
|
||||
|
||||
pub fn insert_test() {
|
||||
assert <<1, 2, 3, 4>> == memory.insert_at(<<1, 2, 3>>, 3, <<4>>)
|
||||
assert <<1, 2, 3, 0, 5>> == memory.insert_at(<<1, 2, 3>>, 4, <<5>>)
|
||||
assert <<1, 67, 3>> == memory.insert_at(<<1, 2, 3>>, 1, <<67>>)
|
||||
}
|
||||
|
||||
pub fn open_test() {
|
||||
let d0 = device.open("0")
|
||||
device.close(d0)
|
||||
}
|
||||
|
||||
pub fn test_device_test() {
|
||||
let d1 = device.open("1")
|
||||
assert <<>> == device.read(d1).0
|
||||
let d1 = device.test_device(d1)
|
||||
assert d1.has_data == True
|
||||
let #(char, d1) = device.read(d1)
|
||||
assert <<"a">> == char
|
||||
assert d1.has_data == False
|
||||
assert <<>> == device.read(d1).0
|
||||
device.close(d1)
|
||||
|
||||
let d0 = device.open("0")
|
||||
let d0 = device.test_device(d0)
|
||||
assert d0.has_data == False
|
||||
device.close(d0)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue