From 2255aaff8b698b85017764ea5a9fe9954820fe32 Mon Sep 17 00:00:00 2001 From: 0x4261756D <38735823+0x4261756D@users.noreply.github.com> Date: Mon, 19 Dec 2022 12:13:40 +0100 Subject: [PATCH] Fix sending detection --- src/main.rs | 8 +++--- tests/rule110.qbl | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 20a31a4..e6a7ee0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -107,12 +107,12 @@ fn main() { let f = f.unwrap(); let file_content = fs::read_to_string(f.path()).unwrap(); - println!("========NOW TESTING '{:?}'========", f.path()); + println!("========NOW TESTING {:?}========", f.path()); match compile(&file_content, &intrinsics, interpret, debug) { Ok(maybe_msg) => { - println!("---Successfully parsed '{:?}'---", f.path()); + println!("---Successfully parsed {:?}---", f.path()); if let Some(msg) = &maybe_msg { print!("---Output---\n'{}'\n", msg); @@ -141,14 +141,14 @@ fn main() println!("===PASSED==="); count += 1; } - else if let Some(index) = file_content.find(":END:") + else if let Some(index) = file_content.find("//:END:") { let expected_output = file_content[10..index].replace("\n//", "\n"); println!("\n\n===FAILED===\nExpected the output to be {}", expected_output); } else { - panic!("Could not find an ending marker (//:END:) for the expected output in {:?}", f.file_name()); + panic!("Could not find an ending marker (:END:) for the expected output in {:?}", f.file_name()); } } } diff --git a/tests/rule110.qbl b/tests/rule110.qbl index 0557be5..af87104 100644 --- a/tests/rule110.qbl +++ b/tests/rule110.qbl @@ -23,3 +23,67 @@ function bool bool bool => bool rule110 } } } + +function int => bool intToBool +{ + 0 != +} + +function bool => int boolToInt +{ + if + { + 1 + } + else + { + 0 + } +} + +true 10 + +true 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +while +{ + check + while + { + // 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + checkAndApply + // 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 true 31 0 0 0 + shift-5 + } +} + +function any any any any any any any any any any any any any any any any any any any any any any any any any any any => any any any any any any any any any any any any any any any any any any any any any any any any any any any shift-5 +{ } + +function int int int int => bool int int int int checkAndApply +{ + check apply +} + +function int => bool int +{ + 0 dup 1 > req - +} + +function int int int => int int int apply +{ + // a b c + intToBool + // b c d + dup intToBool + // c d b e + dup intToBool + // d b e c f + req swp swp + // d e b f c + req req swp + // c d e f b + req rule110 + // b c g + req req boolToInt +}