Skip to content

Handwritten test expansion #257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Nov 16, 2023
22 changes: 21 additions & 1 deletion kmir/src/tests/integration/test-data/handwritten-run-fail.tsv
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
handwritten-rust/fibonacci.mir 134
handwritten-rust/traits/derive-copy-struct.mir 4
handwritten-rust/traits/defined-trait.mir 4
handwritten-rust/structs/struct.mir 4
handwritten-rust/arrays/array.mir 4
handwritten-rust/enums/enum.mir 113
handwritten-rust/generics/generic.mir 4
handwritten-rust/integers/div.mir 113
handwritten-rust/integers/shl_min.mir 2
handwritten-rust/integers/modulo.mir 113
handwritten-rust/floats/float.mir 113
handwritten-rust/strings-chars/std-to-string.mir 4
handwritten-rust/strings-chars/char-trivial.mir 113
handwritten-rust/strings-chars/std-string-empty.mir 113
handwritten-rust/strings-chars/str-empty.mir 4
handwritten-rust/strings-chars/str-trivial.mir 4
handwritten-rust/closures/closure-no-args.mir 1
handwritten-rust/closures/closure-args.mir 1
handwritten-rust/memory/box.mir 113
handwritten-rust/slices/slice.mir 4
handwritten-rust/recursion/fibonacci.mir 134
handwritten-rust/tuples/tuple-eq.mir 4
22 changes: 11 additions & 11 deletions kmir/src/tests/integration/test-data/handwritten-rust/Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
default: mir executables
default: mir

all: mir executables
all: mir exe

clean:
rm -f *.mir
rm -f *.out
find . -name "*.mir" -type f -delete
find . -name "*.out" -type f -delete

RUSTC:=rustc
RUST_SOURCES=$(wildcard *.rs)
RUST_SOURCES=$(shell find . -name '*.rs')
RUSTC_OPTIONS=-C overflow-checks=off -Zmir-enable-passes=-ConstDebugInfo,-PromoteTemps

mir: $(RUST_SOURCES:%.rs=%.mir)
%.mir : %.rs
$(RUSTC) --emit mir $(RUSTC_OPTIONS) $< -o $@
mir: $(patsubst %.rs,%.mir,${RUST_SOURCES})
%.mir: %.rs
$(RUSTC) --emit mir $(RUSTC_OPTIONS) -o $@ $*.rs

executables: $(RUST_SOURCES:%.rs=%.out)
%.out : %.rs
$(RUSTC) $(RUSTC_OPTIONS) $< -o $@
exe: $(patsubst %.rs,%.out,${RUST_SOURCES})
%.out: %.rs
$(RUSTC) $(RUSTC_OPTIONS) -o $@ $*.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// WARNING: This output format is intended for human consumers only
// and is subject to change without notice. Knock yourself out.
fn main() -> () {
let mut _0: ();
let _1: [i32; 4];
let mut _2: bool;
let mut _3: bool;
let mut _4: &[i32; 4];
let mut _5: &[i32; 4];
let _6: [i32; 4];
let mut _7: !;
scope 1 {
debug a => _1;
}

bb0: {
_1 = [const 1_i32, const 2_i32, const 3_i32, const 4_i32];
_4 = &_1;
_6 = [const 1_i32, const 2_i32, const 3_i32, const 4_i32];
_5 = &_6;
_3 = <[i32; 4] as PartialEq>::eq(move _4, move _5) -> bb1;
}

bb1: {
_2 = Not(move _3);
switchInt(move _2) -> [0: bb3, otherwise: bb2];
}

bb2: {
_7 = core::panicking::panic(const "assertion failed: a == [1, 2, 3, 4]");
}

bb3: {
return;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
let a = [1, 2, 3, 4];

assert!(a == [1, 2, 3, 4]);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// WARNING: This output format is intended for human consumers only
// and is subject to change without notice. Knock yourself out.
fn main() -> () {
let mut _0: ();
let _1: [closure@closures/closure-args.rs:2:15: 2:28];
let mut _2: bool;
let mut _3: bool;
let mut _4: i32;
let mut _5: &[closure@closures/closure-args.rs:2:15: 2:28];
let mut _6: (i32, i32);
let mut _7: !;
scope 1 {
debug sum => const ZeroSized: [closure@closures/closure-args.rs:2:15: 2:28];
}

bb0: {
_5 = &_1;
_6 = (const 20_i32, const 22_i32);
_4 = <[closure@closures/closure-args.rs:2:15: 2:28] as Fn<(i32, i32)>>::call(move _5, move _6) -> bb1;
}

bb1: {
_3 = Eq(move _4, const 42_i32);
_2 = Not(move _3);
switchInt(move _2) -> [0: bb3, otherwise: bb2];
}

bb2: {
_7 = core::panicking::panic(const "assertion failed: sum(20, 22) == 42");
}

bb3: {
return;
}
}

fn main::{closure#0}(_1: &[closure@closures/closure-args.rs:2:15: 2:28], _2: i32, _3: i32) -> i32 {
debug x => _2;
debug y => _3;
let mut _0: i32;

bb0: {
_0 = Add(_2, _3);
return;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
let sum = |x, y| -> i32 { x + y };

assert!(sum(20, 22) == 42);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// WARNING: This output format is intended for human consumers only
// and is subject to change without notice. Knock yourself out.
fn main() -> () {
let mut _0: ();
let _1: [closure@closures/closure.rs:2:15: 2:24];
let mut _2: bool;
let mut _3: bool;
let mut _4: u32;
let mut _5: &[closure@closures/closure.rs:2:15: 2:24];
let mut _6: !;
scope 1 {
debug sum => const ZeroSized: [closure@closures/closure.rs:2:15: 2:24];
}

bb0: {
_5 = &_1;
_4 = <[closure@closures/closure.rs:2:15: 2:24] as Fn<()>>::call(move _5, const ()) -> bb1;
}

bb1: {
_3 = Eq(move _4, const 42_u32);
_2 = Not(move _3);
switchInt(move _2) -> [0: bb3, otherwise: bb2];
}

bb2: {
_6 = core::panicking::panic(const "assertion failed: sum() == 42");
}

bb3: {
return;
}
}

fn main::{closure#0}(_1: &[closure@closures/closure.rs:2:15: 2:24]) -> u32 {
let mut _0: u32;

bb0: {
_0 = const 42_u32;
return;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
let sum = || -> u32 { 42 };

assert!(sum() == 42);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// WARNING: This output format is intended for human consumers only
// and is subject to change without notice. Knock yourself out.
fn main() -> () {
let mut _0: ();
let _1: Letter;
scope 1 {
debug a => _1;
}

bb0: {
_1 = Letter::A;
return;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
enum Letter {
A,
B,
}

fn main() {
let a = Letter::A;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// WARNING: This output format is intended for human consumers only
// and is subject to change without notice. Knock yourself out.
fn main() -> () {
let mut _0: ();
let _1: f32;
let mut _3: bool;
let mut _4: bool;
let mut _5: f32;
let mut _6: !;
let mut _9: bool;
let mut _10: bool;
let mut _11: f64;
let mut _12: !;
scope 1 {
debug a => _1;
let _2: f32;
scope 2 {
debug b => _2;
let _7: f64;
scope 3 {
debug c => _7;
let _8: f64;
scope 4 {
debug d => _8;
}
}
}
}

bb0: {
_1 = const 3.5f32;
_2 = const 1.20000005f32;
_5 = Add(_1, _2);
_4 = Eq(move _5, const 4.69999981f32);
_3 = Not(move _4);
switchInt(move _3) -> [0: bb2, otherwise: bb1];
}

bb1: {
_6 = core::panicking::panic(const "assertion failed: a + b == 4.7");
}

bb2: {
_7 = const 3.5f64;
_8 = const 1.2f64;
_11 = Add(_7, _8);
_10 = Eq(move _11, const 4.7000000000000002f64);
_9 = Not(move _10);
switchInt(move _9) -> [0: bb4, otherwise: bb3];
}

bb3: {
_12 = core::panicking::panic(const "assertion failed: c + d == 4.7");
}

bb4: {
return;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
fn main() {
let a:f32 = 3.5;
let b:f32 = 1.2;

assert!(a + b == 4.7);

let c:f64 = 3.5;
let d:f64 = 1.2;

assert!(c + d == 4.7);
}
Loading