-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
49 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
fn f(x) { | ||
print("Okay boomer " + x) | ||
} | ||
|
||
x := f; | ||
x(1); | ||
|
||
# output: | ||
# Okay boomer 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
printadd(1, 2); | ||
|
||
fn printadd(a, b) { | ||
print(a + b); | ||
} | ||
|
||
# output: | ||
# 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
#[cfg(test)] | ||
mod test { | ||
use assert_cmd::Command; | ||
use pretty_assertions::assert_eq; | ||
use saft_macro::discover_tests; | ||
#![cfg(test)] | ||
|
||
#[discover_tests(root = "./tests/res/tests", glob = "**/[!_]*.saf")] | ||
fn test(file_name: &str) { | ||
let mut cmd = Command::cargo_bin("saft").unwrap(); | ||
cmd.arg(file_name); | ||
use assert_cmd::Command; | ||
use pretty_assertions::assert_eq; | ||
use saft_macro::discover_tests; | ||
|
||
let got = String::from_utf8(cmd.unwrap().stdout).unwrap(); | ||
#[discover_tests(root = "./tests/res/tests", glob = "**/[!_]*.saf")] | ||
fn test_file(file_name: &str) { | ||
let mut cmd = Command::cargo_bin("saft").unwrap(); | ||
cmd.arg(file_name); | ||
|
||
let mut expected = Vec::new(); | ||
let got = String::from_utf8(cmd.unwrap().stdout).unwrap(); | ||
|
||
let mut got_output = false; | ||
for line in std::fs::read_to_string(file_name).unwrap().lines() { | ||
if let Some(comment) = line.strip_prefix("# ") { | ||
if got_output { | ||
expected.push(comment.to_string()); | ||
} else if comment == "output:" { | ||
got_output = true; | ||
} | ||
let mut expected = Vec::new(); | ||
|
||
let mut got_output = false; | ||
for line in std::fs::read_to_string(file_name).unwrap().lines() { | ||
if let Some(comment) = line.strip_prefix("# ") { | ||
if got_output { | ||
expected.push(comment.to_string()); | ||
} else if comment == "output:" { | ||
got_output = true; | ||
} | ||
} | ||
|
||
assert_eq!(got.trim(), expected.join("\n").trim()); | ||
} | ||
|
||
assert_eq!(got.trim(), expected.join("\n").trim()); | ||
} |