Add tests for task 1 and 2
This commit is contained in:
106
files/bonus/brainfuck/dank.bf
Normal file
106
files/bonus/brainfuck/dank.bf
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````
|
||||||
|
`````````````````````````````````````````````````````````````````/``````````````````````````````````````````````````````````````
|
||||||
|
````````````````````````````````````````````````````````````````/[``````````````````````````````````````````````````````````````
|
||||||
|
```````````````````````````````````````````````````````````````/-]>`````````````````````````````````````````````````````````````
|
||||||
|
```````````````````````````````````````````````````````````````/[-/`````````````````````````````````````````````````````````````
|
||||||
|
``````````````````````````````````````````````````````````````;]@@@<````````````````````````````````````````````````````````````
|
||||||
|
``````````````````````````````````````````````````````````````>++++;````````````````````````````````````````````````````````````
|
||||||
|
`````````````````````````````````````````````````````````````/++/;++;```````````````````````````````````````````````````````````
|
||||||
|
````````````````````````````````````````````````````````````//+[@@@@</``````````````````````````````````````````````````````````
|
||||||
|
````````````````````````````````````````````````````````````;;+++++++/``````````````````````````````````````````````````````````
|
||||||
|
```````````````````````````````````````````````````````````;;;;//;/++@>`````````````````````````````````````````````````````````
|
||||||
|
``````````````````````````````````````````````````````````//-;;;;;]@@@<`````````````````````````````````````````````````````````
|
||||||
|
``````````````````````````````````````````````````````````/----@@@@@@@@.````````````````````````````````````````````````````````
|
||||||
|
`````````````````````````````````````````````````````````>++++++[@@@@@@<````````````````````````````````````````````````````````
|
||||||
|
`````````````````````````````````````````````````````````;+;;;;/;/;;;;++/```````````````````````````````````````````````````````
|
||||||
|
````````````````````````````````````````````````````````/+;;;;;;;;/;;;++>```````````````````````````````````````````````````````
|
||||||
|
```````````````````````````````````````````````````````/-]@<;;--@@@@@@@@@.``````````````````````````````````````````````````````
|
||||||
|
```````````````````````````````````````````````````````>++++[@@@@@@@@@@@@</`````````````````````````````````````````````````````
|
||||||
|
``````````````````````````````````````````````````````;----@@>;;;;;;-]@@@</`````````````````````````````````````````````````````
|
||||||
|
`````````````````````````````````````````````````````/++@.>;;;;;;;;;;;;;/++/````````````````````````````````````````````````````
|
||||||
|
`````````````````````````````````````````````````````;++/;;;;;;;//;;;;/;;[@<````````````````````````````````````````````````````
|
||||||
|
````````````````````````````````````````````````````/++;;;;;/;;++@@>;//;-]<;/```````````````````````````````````````````````````
|
||||||
|
```````````````````````````````````````````````````/;+@@@@@@@@@@@@@@@@@@@@@@.```````````````````````````````````````````````````
|
||||||
|
```````````````````````````````````````````````````>+++++[@@@@@@<;;;-----@@@@>``````````````````````````````````````````````````
|
||||||
|
``````````````````````````````````````````````````/-]@</;//;;/;;/;;;;;;/;;;;;;``````````````````````````````````````````````````
|
||||||
|
``````````````````````````````````````````````````;-;;;;;;///;;/;;;;;;;;;;;;/;/`````````````````````````````````````````````````
|
||||||
|
`````````````````````````````````````````````````/--/;;;;;;;/;;/;;//;/;;;;;;;-;/````````````````````````````````````````````````
|
||||||
|
````````````````````````````````````````````````/-@@.>;/;;/;;++/;;/;+//;;;///+[<````````````````````````````````````````````````
|
||||||
|
````````````````````````````````````````````````++++@@@@@@>;-]@<;/;+@.>;++;;/++;/```````````````````````````````````````````````
|
||||||
|
```````````````````````````````````````````````;[@@@@</++;/;;;;;/;/////;;;;;/++>;```````````````````````````````````````````````
|
||||||
|
``````````````````````````````````````````````/-]@<///;;/;;;;///;;;;/;;/;/;;--@@.;``````````````````````````````````````````````
|
||||||
|
``````````````````````````````````````````````/+@.;/;;;;;;;;;;;;;//;-.;;/;;/@@@@;/``````````````````````````````````````````````
|
||||||
|
`````````````````````````````````````````````/@@@//;/;;/;;;;/;/;;;;/;@;;;;;;;;;@@/;`````````````````````````````````````````````
|
||||||
|
`````````````````````````````````````````````;@@@@@@@@@@@@@@@@@@@@;/;@@@;;;;;/;;@@;`````````````````````````````````````````````
|
||||||
|
````````````````````````````````````````````/;@@@@@@@@@@@@@@@/;/;;;;;@@//;@@@@;;@@;;````````````````````````````````````````````
|
||||||
|
```````````````````````````````````````````/;;;/;//////;//;/;;;;//;;///;//@@@@/;@@@;````````````````````````````````````````````
|
||||||
|
```````````````````````````````````````````/;//;/;@@@@/;;;/;;;;//;///;;;;;;;///@@@@@/```````````````````````````````````````````
|
||||||
|
``````````````````````````````````````````/@@@@@@@@@@;/;;;/;;;;;/;;////;;;/;;;;;;@@@//``````````````````````````````````````````
|
||||||
|
`````````````````````````````````````````/@@@@@@;//;/;/;;@@@/;;@@@;/;@@@@@/;;;;/;//@;;``````````````````````````````````````````
|
||||||
|
`````````````````````````````````````````@@@//;;;;;;@;/;/@@@;;;@@;/;;@@@@@///@@@;;;/@;/`````````````````````````````````````````
|
||||||
|
````````````````````````````````````````/@@/;/;@@@@@@@////;;/;;/;;;;;//;;;//@@@@@;;/@@/`````````````````````````````````````````
|
||||||
|
```````````````````````````````````````/;@@@@@@@@@@;//;;;/;;/;;;;//;;;;;/;;;@;/;@;;;@@@/````````````````````````````````````````
|
||||||
|
```````````````````````````````````````/@@@@@@@/;;//@@@@@@@;@@@@@@/;;;/;;;@@/;;;/@@@@@@;````````````````````````````````````````
|
||||||
|
``````````````````````````````````````/@@@;/@;//;@@@@@@@@@@@@@@@@@@@@@@@@@@@/;;;;@@@@@@@;```````````````````````````````````````
|
||||||
|
``````````````````````````````````````;@/;@@;/;@@@@@@@@@@;;@@@@@@;///;@@@@@@@;;;@@@/;;@@//``````````````````````````````````````
|
||||||
|
`````````````````````````````````````/;@@@@;/@@@@@@@@@@;;@@@@@;;;@@@@@@@@@@@@@@@@@@@;/;@@;``````````````````````````````````````
|
||||||
|
````````````````````````````````````;//@@@;;@@@@@@@@;/;;@@@@;/;@@@@@@@@@@@@@@@@@@@@@@@/;;;/`````````````````````````````````````
|
||||||
|
````````````````````````````````````;@@;;/@@@@@@@@;///;;@;//;/@@@@;;/;;@@@@@@@@@@@@@@@;//@;`````````````````````````````````````
|
||||||
|
```````````````````````````````````/@@@@@@@@@@@@//;@@/;;/;;;;;;/;/;/;;@@@@@@@;;//;//@@@;@@;/````````````````````````````````````
|
||||||
|
``````````````````````````````````/;@@@@@@@@@;;;/;;;;;;;;;;;;/;;;;///@@;/;;;;//@@@@@@@@//@@/````````````````````````````````````
|
||||||
|
``````````````````````````````````/@@@@@@@@@/;;@;;/;/;;@;;;;;;/;;/;/@@//;;;;;/@@@@@@/;//@@@@/```````````````````````````````````
|
||||||
|
`````````````````````````````````/@@@@@@@@@@;;@@/;;;/;;;;;;;;@;;//;@@/;;;;;;;@@;/@@@@@@@@@@@@```````````````````````````````````
|
||||||
|
`````````````````````````````````;@@@@@//;/;/@@@;;;;/;;//;;;////;@@@@/;///;@@@@/;;/@@@@;//@@@/``````````````````````````````````
|
||||||
|
````````````````````````````````/@;/@@@@@;;;;@;;;;/;/@@@@@@@@@@@@@@@@@;/;@@@//;;/;/@@;//@@@@@;``````````````````````````````````
|
||||||
|
```````````````````````````````/@@//@@@@@@;@@//;;@@@@@@@@;;/@@@@;;;;@@@@@@@@;;/@@@@@@/;;@@@@@@/`````````````````````````````````
|
||||||
|
```````````````````````````````@@@@@@//@@@@@@@@@@@@@@@@;;;;;@@@/;;@;//@@@@@@@//@@@@;/;;;;@@@@@//````````````````````````````````
|
||||||
|
``````````````````````````````;@@@@@@@@@@@@@@@@@;/;;/;;;;/;@@;;///@@@@@@@@@@@@@@@/;/;;@@@@@/;@@/````````````````````````````````
|
||||||
|
`````````````````````````````//;;@@@@@@@/;@@;;;;@@;;;/;;;;;;;//;/;;;;@@@@@@@@@@@@;;;;@@@@@;;@@@;/```````````````````````````````
|
||||||
|
`````````````````````````````;@@@@@;@@@@@@;;;;;/;@///;;;;;;;;;;/;;;/;;/;/;@@@@///@@@@@//@@@@@@@@/```````````````````````````````
|
||||||
|
````````````````````````````/;@@@@@//@@@@//@@/;//;;;;;;;;;;;;;;;;;;/;/;;;;;/@@@@/@@@@/;;@@@@@@@@//``````````````````````````````
|
||||||
|
```````````````````````````///;@@@@@@@@;;/;@@/;;;;;;;;;;;;;;;;;;;/;@@@;/;;//;/@@@/@@@;;;@@@@@@@@@/``````````````````````````````
|
||||||
|
```````````````````````````/;@;@@@@@@@/;/;@/;;;/;;;//;//////////;;;@@;;/;/;@@;//;;/@@@@@@@@@@@@@@@;`````````````````````````````
|
||||||
|
``````````````````````````//@@@@@@@@@;;@@;/;;;;;;/;@@@@@@@@@@@@@@@@@@@@;;;;@@@@///;@@@@@//@@@@@@@@@`````````````````````````````
|
||||||
|
``````````````````````````;@@@@@@@@@@/;;;;/;;;;@@@@@@@@@@@@@@@@@@@@@@@@@@@;;/@@@@/;;@@@@@@@@@@@@@@@/````````````````````````````
|
||||||
|
`````````````````````````/@@;/;@@@@@@/;/;;;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@;/;;@@@;;;@@@@@@@;;@@@@@@/```````````````````````````
|
||||||
|
````````````````````````;@@@/@@@@///;;/;@@@@@@@@@@@@@@@@@;//;@@@@@@@@@@@@@@@@;;/;@@@;/@@@@@/;;/@@@@@;```````````````````````````
|
||||||
|
````````````````````````@@@@@@@@/;/;/;@@@@@@@@@@@@@@;///;//@@@@@@@@@;@@@@@@@@@@@/;;@@//;@@@;//@@@@@@@/``````````````````````````
|
||||||
|
```````````````````````/@@@@/;;;;;@@@@@@@@@@@@@@@@@;;;;;/;@@@@@@@@@@/@@@@@@@@@@@@/;;@@@//@@@/;@@@@@@@/``````````````````````````
|
||||||
|
``````````````````````/@@@@@;/;;;@@@@@@@@@@@@;/@@@@/;;;;/;@@@@@@@@@@/@@@@@@//;@@@@@;;;@@;/@@@;/@@@@@@@/`````````````````````````
|
||||||
|
``````````````````````@@@@;;;;;;;@;@@@@@@/@@@/@@@@@;;;;;;/;@@@@@@@@@/@@@@@@@//;;@@@@;;;@@@;@@@@@@@@@@@@`````````````````````````
|
||||||
|
`````````````````````;@@@@;;;;//@@@@@@@@@/@@@@@@@@@@;;;;;;/@@@@@@@@@;@@@@@@/@@@//@@@@;;/@@@@@@@@@@@@@@@;````````````````````````
|
||||||
|
`````````````````````@@@@@@//;@@@@@@@@@@@;;@@@;@@@@@//;/;/@@@@@@@@@;@@@@@@@/;@@;;;@@@@@/;@@@@@@@@@@@@@@@````````````````````````
|
||||||
|
````````````````````/@@@@//;@@@@@@@@@@@@@;/;@@/@@@@@@;//;;@@@@@@@@@/@@@@@@;;;@@@;/@@@@@@;/;@@;//@@@@;;/@/```````````````````````
|
||||||
|
```````````````````/@@@;///@@@@@@@@@@@/@@@;;@@@/@@@;@@@;@@@@@@@@@@;/@@@@@@;/;@@;;@@@@@@@@@//@@@;/;@/;/;@@/``````````````````````
|
||||||
|
```````````````````;@@@/;;@@@@@@@@@;@@/;@@/;;@@;/@@;/@@@@@@@@@@@@@/@@@@@@@/;;@@;/@@@@@@@@@@;@@@@;;/;@@@@@;``````````````````````
|
||||||
|
``````````````````/@@@@;;/@@@@@@@@@/@@;/@@@;;;@@@/@@@;/@@@@@@@@/;/;@@@@@@;;;/@;;/@@@@@@@@@;///;/;;;@@@@@@@/`````````````````````
|
||||||
|
`````````````````/;;@@@;;;@@@@@@@@@@;;/;/@@/;;/@@@;/@@;////;//;/;;@@@@@@@/;;@@;;/@@@@@@@@;//@@;;;@@@;@@@@@/`````````````````````
|
||||||
|
`````````````````/@@/;@@//@@@@@@@@@@@@@;/@@;/;;/@@@@/;;@@;;@@;/;@@@@@@@@;;/@@;;/@@@@@@@;/;@@@;;@@@@@//;/;;/;````````````````````
|
||||||
|
````````````````/;@@/;@@@;;@@@@@@@@@@@@@/;@@;;@@@/@@@@@@@;/@@@@@@@@@@@@@/;@@;;;/@@@@@@/;;@@@/;@@@@@@@;///@@;````````````````````
|
||||||
|
```````````````//@@@;//@@@;;/;/;;@@@@@@@;/@@//;@@@@@@@@@@@;@@@@@@@@@@@/;;@@;;//@@@@@;/;/@@@/;@@@;/;@@@@@@@@@@```````````````````
|
||||||
|
```````````````/@@@/;;;/@@@@;;;;;;/@@@@@@;;@@;;;/@@@@@@@@@@@@@@@@@@@@/;/;@@/;/@@@@//;@@@@;/@@@/;;/;/;@@@@@;@@```````````````````
|
||||||
|
``````````````//@@@/;;;;;/@@@;/;@;/;;@@@@;;/@;/;;/;@@@@@@@@@@@@@@@@;;;;;@@/;;@@;;//;@@@@@@@@@/;@@@;;//;@@@@;@@``````````````````
|
||||||
|
``````````````/@@@@@////;;/@;;//@@///;@@/;/;@@/;;;//;@@@@@@@@@@@@;;/;;;@@@;;;@;//;@@@@@@@@@@@/;@@@@;/;;/;//@@@/`````````````````
|
||||||
|
`````````````/@@/;@@@@@@@@@/;;/;//;;;;;;;;@@;/@@;;;;;;/////////;;;;;;/;@@;;/;;;/@@@@//@@;@@@@;;;/;@@@;;;;/@@@@@`````````````````
|
||||||
|
````````````/;@;//;;@@@@@@;/;;//;/;;//;;;///;;/@@;;;;;;;;;;;;;;;;;;;;;;;;;;///@@@@@@;@@@//@@@/////@@@@@@@@@@@@@;````````````````
|
||||||
|
````````````;@@/;;/;/@@@//;;;@@;;;/;;;;;;;/;;/;/;;/;;;;;;;;;/;;;/;;;;;;;/@@@@@;;@@@@@@@@@@@;;/;;/@@@@@@@@@@//;@@````````````````
|
||||||
|
```````````/@@@@@;;;/@@@/;//;/;;;/@@@;;;;;/;///;///;;/;;;;;;;/;/;//;;;@@@@@@@@///;//;///;;//@//;@@@//;/@@@@;;;;@@```````````````
|
||||||
|
``````````/;@@@@@@//@@@@;;;//;;;;/;@@/;;;;;;;@@@@@@@@@@@;;;/;@@@@@@@@@@@;;//@@@;;;;;;;/;;/;@@@@;@/@/;;/;/@@@//;@@```````````````
|
||||||
|
``````````/@@//;@@;;@@;/;/@@;;;/;;;;///;;;;;;;/;;/;@@@@@@@@@@@@@@@;/;;/;/;@@@;;;;;;;@@@/;;/;;@@@@/;@@;/;/@@@@@@@@@``````````````
|
||||||
|
`````````/@@///;;@@////;;;;//;@@@///;;;;;;;;;@@/;;/;;;;//;@@@;;@@//;;;@/;;;/;///;@@@@@;;;;;;;;;@@//;/;/@@@@@@@@@@@``````````````
|
||||||
|
`````````;@@@@@@@@@@;;;;;;;;;;@@@/;/@;;;;;;;;@;;;;;;//@@;;/@;;;;@@/;;;;;///;@@@@@@@@;;;;;;;//;@@@@@@@@@@@@@@@@@@@/;`````````````
|
||||||
|
````````/@@@@@@@@@@@@@@;///;;;;;///;@@;;;;;;/;;;;;;;;/;@;;;;;;;;;;;;;/;;@@@@@@@@@///;;;/;;@@@@@@@@@@@@@////;//;@@@/`````````````
|
||||||
|
```````/@@@;/;;;@@@@@@@@@@@/;;;;;;;;@;//@@@@@@@;;;;;;;;;;;;;;;;;;;;@@@@@@@@;/;;/;/;;@@@@@@@@@@;;;//;;@@@;/;;;;;;/;;/````````````
|
||||||
|
```````/@@/;/;@@/;;;//@@@@;;/;;/;;;;/;;///;;@@@@@@@@@@@@@@@@@@@@@@@@@@;;;;//;;;@@@@@@@@@@@@@@@/;;;;/;;@@@@;///;;@@@@/```````````
|
||||||
|
``````/@@@@;//;@@;//;/;@@@//;@@@@/;///;/;/;;;/;/;/;;;/;/;;//;;;;;/;;;/;;;/;@@@@@@@@@;/;;;;;;@@@;;;;;;/@@@@@@@@@@@@@@/```````````
|
||||||
|
`````/;@@@@@@@@@@@//;;;;@@///;//;@@@@@@@@@@;;;////;;;////////;//;;@@;;@@@@@@@@@@;;;;;;/;;;;/;@@@@@@;@@@@@@@@@@@;/;/;/;``````````
|
||||||
|
`````;/@@@@@@@@@@@@@@@@@/;;;;;;;;;/;@;/;/@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@;;/;///;/;/;;;;;;/;;@@@@@@@@@@@@;@@@@@@@/;;;/;@``````````
|
||||||
|
````;;//@@@;//;;;@@@@@@@;;;;;;/;;;/;;//;;;/////;;;;;@@@@@@@@@;;;//;/;;;;;;;;;;;;//;;;;/@@@@@@;/;;;@@@@@/;;;;//;;;;//@@@`````````
|
||||||
|
```/;;@@@@@/;/;;;/;@@@@//;;@@@;;;;;;;;;;;/;;@/;;;;;;;;//;;;;;;;/;;;///;;///@@;/;@@@@/;;@@@@@//;;;;//;@@@@///@@@/@@@@@@@`````````
|
||||||
|
```/;@@@@@@@;;;;;;;/@@@;//;@;;;@@@@/;/;;;;;;/;;/;;;;;;;@/;;/;@@;;;;@@@;;;@@@@;;;@@@;;///;//@/;;/;;//;@@@@@;/@@@;@@@@@@@;````````
|
||||||
|
``//@@@/;/@@@@@/;;;@@@@;;;;;;;;;;@@/;;;@//;;;;;;;;/;;;@@/;;;;;;;;;/@@;;/;/@;/;/;/;;/////;;/@@@//@@@@@;;;@@@@@@@;/;;@@@;;````````
|
||||||
|
``/@@@@;;;/@@@@@//@@@;/@@;;/////;;;/;;@@@;/;;;;/;;;;;;;/;;;;;;/;;/;;;;;;;;;/;;;////;@@/;;;@@@@;;@@@@;;;;;/@@@;;;;@@@@@@@@```````
|
||||||
|
`/@@@@@/@@@/;;@@;;/;/;//@@@@@@@@@@@@@@;;///@@@/;;;/@//;;@@/;;@//;;;;;/@@;;;;@@@@;;;@@@;;;@@@;/;;;/;;;;;;;;@@;;/;@@@@@@@@;/``````
|
||||||
|
;;;@@@@;@@@/;;/@@;;/;;;;;;;;/;@@/;/;@;;;;;/;@@/;;;;;;;/;;/;;;@//;;;;;;@@;;;;@@;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;//``````
|
||||||
|
````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````
|
||||||
|
````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````
|
||||||
14
files/bonus/brainfuck/hello_world.bf
Normal file
14
files/bonus/brainfuck/hello_world.bf
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
++++++++++ init multiplier
|
||||||
|
[>+++++++>++++++++++>+++>+<<<<-] multiply cells 1 2 3 4 with the 10 in 0
|
||||||
|
>++. H
|
||||||
|
>+. e
|
||||||
|
+++++++.. ll
|
||||||
|
+++. o
|
||||||
|
>++. space
|
||||||
|
<<+++++++++++++++. W
|
||||||
|
>. o
|
||||||
|
+++. r
|
||||||
|
------. l
|
||||||
|
--------. d
|
||||||
|
>+. !
|
||||||
|
>. new line
|
||||||
27
files/task3/IFEQ1
Normal file
27
files/task3/IFEQ1
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
.constant
|
||||||
|
.end-constant
|
||||||
|
|
||||||
|
.main
|
||||||
|
|
||||||
|
L1:
|
||||||
|
BIPUSH 0x05
|
||||||
|
L2:
|
||||||
|
DUP
|
||||||
|
BIPUSH 0x30
|
||||||
|
IADD
|
||||||
|
OUT
|
||||||
|
BIPUSH 0x01
|
||||||
|
ISUB
|
||||||
|
DUP
|
||||||
|
IFEQ L3
|
||||||
|
GOTO L2
|
||||||
|
L3:
|
||||||
|
BIPUSH 0x65
|
||||||
|
BIPUSH 0x6E
|
||||||
|
BIPUSH 0x6F
|
||||||
|
BIPUSH 0x64
|
||||||
|
OUT
|
||||||
|
OUT
|
||||||
|
OUT
|
||||||
|
OUT
|
||||||
|
.end-main
|
||||||
30
files/task3/IFLT1
Normal file
30
files/task3/IFLT1
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
.constant
|
||||||
|
.end-constant
|
||||||
|
|
||||||
|
.main
|
||||||
|
|
||||||
|
L1:
|
||||||
|
BIPUSH 0x00
|
||||||
|
IFLT L6
|
||||||
|
L2:
|
||||||
|
BIPUSH 0x01
|
||||||
|
IFLT L6
|
||||||
|
L3:
|
||||||
|
BIPUSH 0xFF
|
||||||
|
IFLT L6
|
||||||
|
L4:
|
||||||
|
BIPUSH 0x10
|
||||||
|
BIPUSH 0x11
|
||||||
|
ISUB
|
||||||
|
IFLT L6
|
||||||
|
L5:
|
||||||
|
BIPUSH 0x00
|
||||||
|
BIPUSH 0x00
|
||||||
|
BIPUSH 0x00
|
||||||
|
BIPUSH 0x00
|
||||||
|
BIPUSH 0x00
|
||||||
|
HALT
|
||||||
|
L6:
|
||||||
|
BIPUSH 0x37
|
||||||
|
HALT
|
||||||
|
.end-main
|
||||||
BIN
files/testmem.bin
Normal file
BIN
files/testmem.bin
Normal file
Binary file not shown.
10
src/block.rs
10
src/block.rs
@@ -1,3 +1,5 @@
|
|||||||
|
use std::ops;
|
||||||
|
|
||||||
use Result;
|
use Result;
|
||||||
use binread::BinReadable;
|
use binread::BinReadable;
|
||||||
|
|
||||||
@@ -45,6 +47,14 @@ impl Block {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ops::Index<usize> for Block {
|
||||||
|
type Output = u8;
|
||||||
|
|
||||||
|
fn index(&self, index: usize) -> &<Self as ops::Index<usize>>::Output {
|
||||||
|
return &self.source[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl BinReadable for Block {
|
impl BinReadable for Block {
|
||||||
fn get(&mut self) -> Result<u8> {
|
fn get(&mut self) -> Result<u8> {
|
||||||
if self.pointer >= self.length {
|
if self.pointer >= self.length {
|
||||||
|
|||||||
@@ -9,3 +9,5 @@ pub mod frame;
|
|||||||
pub mod netstack;
|
pub mod netstack;
|
||||||
|
|
||||||
type Result<T> = ::std::result::Result<T, &'static str>;
|
type Result<T> = ::std::result::Result<T, &'static str>;
|
||||||
|
|
||||||
|
pub use machine::Machine;
|
||||||
|
|||||||
34
tests/task1.rs
Normal file
34
tests/task1.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
extern crate rustijvm;
|
||||||
|
|
||||||
|
use rustijvm::binread::BinReadable;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn task1_program1() {
|
||||||
|
let machine = rustijvm::Machine::new_from_file("files/task1/program1.ijvm").unwrap();
|
||||||
|
assert_eq!(machine.block.len(), 7);
|
||||||
|
assert_eq!(machine.block[0], 0x10); // BIPUSH
|
||||||
|
assert_eq!(machine.block[2], 0x10); // BIPUSH
|
||||||
|
assert_eq!(machine.block[4], 0x60); // IADD
|
||||||
|
assert_eq!(machine.block[5], 0xFD); // OUT
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn task1_program2() {
|
||||||
|
let machine = rustijvm::Machine::new_from_file("files/task1/program2.ijvm").unwrap();
|
||||||
|
assert_eq!(machine.block.len(), 16);
|
||||||
|
assert_eq!(machine.block[0], 0x0);
|
||||||
|
assert_eq!(machine.block[1], 0x13);
|
||||||
|
assert_eq!(machine.block[4], 0x59);
|
||||||
|
assert_eq!(machine.block[5], 0x13);
|
||||||
|
assert_eq!(machine.block[8], 0x60);
|
||||||
|
assert_eq!(machine.block[9], 0x13);
|
||||||
|
assert_eq!(machine.block[12], 0x60);
|
||||||
|
assert_eq!(machine.block[13], 0xFD);
|
||||||
|
assert_eq!(machine.block[14], 0x0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn task1_program_counter() {
|
||||||
|
let machine = rustijvm::Machine::new_from_file("files/task1/program1.ijvm").unwrap();
|
||||||
|
assert_eq!(machine.get_program_counter(), 0);
|
||||||
|
}
|
||||||
88
tests/task2.rs
Normal file
88
tests/task2.rs
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
extern crate rustijvm;
|
||||||
|
|
||||||
|
fn steps(machine: &mut rustijvm::Machine, num: usize) {
|
||||||
|
for _ in 0..num {
|
||||||
|
println!("step");
|
||||||
|
machine.step().unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn task2_simple_bipush() {
|
||||||
|
let mut machine = rustijvm::Machine::new_from_file("files/task2/TestBipush1.ijvm").unwrap();
|
||||||
|
steps(&mut machine, 1);
|
||||||
|
assert_eq!(machine.cur_stack().top(), Ok(42));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn task2_signed_bipush() {
|
||||||
|
let mut machine = rustijvm::Machine::new_from_file("files/task2/TestBipush2.ijvm").unwrap();
|
||||||
|
steps(&mut machine, 1);
|
||||||
|
assert_eq!(machine.cur_stack().top(), Ok(-42));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn task2_simple_iadd() {
|
||||||
|
let mut machine = rustijvm::Machine::new_from_file("files/task2/TestIadd1.ijvm").unwrap();
|
||||||
|
steps(&mut machine, 3);
|
||||||
|
assert_eq!(machine.cur_stack().top(), Ok(60));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn task2_signed_iadd() {
|
||||||
|
let mut machine = rustijvm::Machine::new_from_file("files/task2/TestIadd2.ijvm").unwrap();
|
||||||
|
steps(&mut machine, 3);
|
||||||
|
assert_eq!(machine.cur_stack().top(), Ok(-60));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn task2_simple_isub() {
|
||||||
|
let mut machine = rustijvm::Machine::new_from_file("files/task2/TestIsub1.ijvm").unwrap();
|
||||||
|
steps(&mut machine, 3);
|
||||||
|
assert_eq!(machine.cur_stack().top(), Ok(-10));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn task2_signed_isub() {
|
||||||
|
let mut machine = rustijvm::Machine::new_from_file("files/task2/TestIsub2.ijvm").unwrap();
|
||||||
|
steps(&mut machine, 3);
|
||||||
|
assert_eq!(machine.cur_stack().top(), Ok(10));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn task2_simple_iand() {
|
||||||
|
let mut machine = rustijvm::Machine::new_from_file("files/task2/TestIAND1.ijvm").unwrap();
|
||||||
|
steps(&mut machine, 5);
|
||||||
|
assert_eq!(machine.cur_stack().top(), Ok(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn task2_simple_ior() {
|
||||||
|
let mut machine = rustijvm::Machine::new_from_file("files/task2/TestIOR1.ijvm").unwrap();
|
||||||
|
steps(&mut machine, 5);
|
||||||
|
assert_eq!(machine.cur_stack().top(), Ok(127));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn task2_swap() {
|
||||||
|
let mut machine = rustijvm::Machine::new_from_file("files/task2/TestSwap1.ijvm").unwrap();
|
||||||
|
steps(&mut machine, 1);
|
||||||
|
assert_eq!(machine.cur_stack().top(), Ok(10));
|
||||||
|
steps(&mut machine, 1);
|
||||||
|
assert_eq!(machine.cur_stack().top(), Ok(20));
|
||||||
|
steps(&mut machine, 1);
|
||||||
|
assert_eq!(machine.cur_stack().top(), Ok(10));
|
||||||
|
steps(&mut machine, 1);
|
||||||
|
assert_eq!(machine.cur_stack().top(), Ok(20));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn task2_simple_stack_operations() {
|
||||||
|
let mut machine = rustijvm::Machine::new_from_file("files/task2/TestPop1.ijvm").unwrap();
|
||||||
|
steps(&mut machine, 3);
|
||||||
|
assert_eq!(machine.cur_stack().top(), Ok(10));
|
||||||
|
steps(&mut machine, 3);
|
||||||
|
assert_eq!(machine.cur_stack().top(), Ok(50));
|
||||||
|
steps(&mut machine, 1);
|
||||||
|
assert_eq!(machine.cur_stack().top(), Ok(10));
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user