diff --git a/Cargo.lock b/Cargo.lock index 1236ce1d..9b5b917d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24,6 +24,7 @@ dependencies = [ "predicates", "similar-string", "tempfile", + "test-generator", "tiny_http", ] @@ -208,9 +209,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" dependencies = [ "heck", - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.86", + "quote 1.0.36", + "syn 2.0.68", ] [[package]] @@ -284,6 +285,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "heck" version = "0.5.0" @@ -444,6 +451,15 @@ dependencies = [ "termtree", ] +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + [[package]] name = "proc-macro2" version = "1.0.86" @@ -453,13 +469,22 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2 0.4.30", +] + [[package]] name = "quote" version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.86", ] [[package]] @@ -519,9 +544,9 @@ version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.86", + "quote 1.0.36", + "syn 2.0.68", ] [[package]] @@ -536,14 +561,25 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "unicode-xid", +] + [[package]] name = "syn" version = "2.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.86", + "quote 1.0.36", "unicode-ident", ] @@ -565,6 +601,18 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" +[[package]] +name = "test-generator" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b23be2add79223226e1cb6446cb3e37506a5927089870687a0f1149bb7a073a" +dependencies = [ + "glob", + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", +] + [[package]] name = "tiny_http" version = "0.12.0" @@ -589,6 +637,12 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + [[package]] name = "utf8parse" version = "0.2.2" @@ -623,9 +677,9 @@ dependencies = [ "bumpalo", "log", "once_cell", - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.86", + "quote 1.0.36", + "syn 2.0.68", "wasm-bindgen-shared", ] @@ -635,7 +689,7 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ - "quote", + "quote 1.0.36", "wasm-bindgen-macro-support", ] @@ -645,9 +699,9 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.86", + "quote 1.0.36", + "syn 2.0.68", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/Cargo.toml b/Cargo.toml index 10cd080f..2a147db2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ itertools = "0.11.0" clap = { version = "4.4.18", features = ["derive"] } tempfile = "3.10.1" chrono = "0.4.38" +test-generator = "0.3.1" # test dependencies [dev-dependencies] diff --git a/src/std/main.ab b/src/std/main.ab index 187d6967..dc2a46b9 100644 --- a/src/std/main.ab +++ b/src/std/main.ab @@ -186,7 +186,7 @@ pub fun make_executable(path: Text): Bool { return false } -pub fun switch_user_permission(user: Text, path: Text): Bool { +pub fun change_owner(user: Text, path: Text): Bool { if file_exist(path) or dir_exist(path) { unsafe $chown -R "{user}" "{path}"$ return true diff --git a/src/tests/stdlib.rs b/src/tests/stdlib.rs index 7777a5df..2daf7fa5 100644 --- a/src/tests/stdlib.rs +++ b/src/tests/stdlib.rs @@ -1,26 +1,26 @@ +#![cfg(test)] +extern crate test_generator; +use test_generator::test_resources; use crate::compiler::AmberCompiler; use crate::test_amber; use crate::tests::compile_code; use std::fs; -use std::io::Read; use std::io::Write; -use std::path::PathBuf; use std::time::Duration; -use tempfile::tempdir; -use tempfile::TempDir; use std::process::{Command, Stdio}; -fn mkfile() -> (PathBuf, TempDir) { - let temp_dir = tempdir().expect("Failed to create temporary directory"); - assert!(temp_dir.path().is_dir(), "Temp directory is not a directory!"); +/* + * Autoload the Amber test files for stdlib and match the output with the output.txt file + */ +#[test_resources("src/tests/stdlib/*.ab")] +fn amber_test(input: &str) { + let code = fs::read_to_string(input) + .expect(&format!("Failed to open {input} test file")); - let file_path = temp_dir.path().join("test_file.txt"); + let output = fs::read_to_string(input.replace(".ab", ".output.txt")) + .expect(&format!("Failed to open {input}.output.txt file")); - let mut file = fs::File::create(&file_path).expect("Failed to create temporary file"); - file.write_all(b"This is a sample file.\n").expect("Failed to write to temporary file"); - file.flush().expect("Failed to flush file"); - - (file_path, temp_dir) + test_amber!(code, output); } fn http_server() { @@ -36,13 +36,9 @@ fn http_server() { #[test] fn input() { let prompt_message = "Please enter your name:"; - let code = format!(r#" - import * from "std" - main {{ - let name = input("{}") - echo "Hello, " + name - }} - "#, prompt_message); + + let code = fs::read_to_string("src/tests/stdlib/no_output/input.ab") + .expect(&format!("Failed to open stdlib/no_output/input.ab test file")); let input = "Amber"; let expected_output = format!("{}Hello, {}", prompt_message, input); @@ -68,317 +64,11 @@ fn input() { assert_eq!(output_str.trim_end_matches('\n'), expected_output); } -#[test] -fn replace_once() { - let code = " - import * from \"std\" - main { - echo replace_once(\"hello world!\", \"world\", \"Amber\") - } - "; - - test_amber!(code, "hello Amber!") -} - -#[test] -fn replace() { - let code = " - import * from \"std\" - main { - echo replace(\"banana banana\", \"banana\", \"apple\") - } - "; - test_amber!(code, "apple apple") -} - -#[test] -fn replace_regex() { - let code = " - import * from \"std\" - main { - echo replace_regex(\"abc123def\", \"[0-9][0-9]*\", \"456\") - } - "; - test_amber!(code, "abc456def") -} - -#[test] -fn file_read() { - let (file_path, temp_dir) = mkfile(); - - let code = format!( - " - import * from \"std\" - main {{ - let f = file_read(\"{file_path}\") failed {{ echo \"Failed\" }} - echo f - }} - ", - file_path = file_path.to_str().unwrap() - ); - - test_amber!(code, "This is a sample file."); - - temp_dir.close().expect("Couldn't close temp dir"); -} - -#[test] -fn file_write() { - let (file_path, temp_dir) = mkfile(); - - let code = format!( - " - import * from \"std\" - main {{ - unsafe file_write(\"{file_path}\", \"Hello, Amber!\") - }} - ", - file_path = file_path.to_str().unwrap() - ); - - test_amber!(code, ""); - - let mut file_content = String::new(); - fs::File::open(&file_path) - .expect("Failed to open temporary file") - .read_to_string(&mut file_content) - .expect("Failed to read from temporary file"); - - assert_eq!(file_content.trim(), "Hello, Amber!"); - - temp_dir.close().expect("Couldn't close temp dir"); -} - -#[test] -fn file_append() { - let (file_path, temp_dir) = mkfile(); - - let code = format!( - " - import * from \"std\" - main {{ - unsafe file_append(\"{file_path}\", \"Appending this line.\") - }} - ", - file_path = file_path.to_str().unwrap() - ); - - test_amber!(code, ""); - - let mut file_content = String::new(); - fs::File::open(&file_path) - .expect("Failed to open temporary file") - .read_to_string(&mut file_content) - .expect("Failed to read from temporary file"); - - assert_eq!(file_content.trim(), "This is a sample file.\nAppending this line."); - - temp_dir.close().expect("Couldn't close temp dir"); -} - -#[test] -fn split() { - let code = " - import * from \"std\" - main { - let array = split(\"apple,banana,cherry\", \",\") - echo array[1] - } - "; - test_amber!(code, "banana") -} - -#[test] -fn split_multiline() { - let code = " - import * from \"std\" - main { - let array = split(\"apple,ban\nana,cherry\", \",\") - echo array - } - "; - test_amber!(code, "apple ban\nana cherry") -} - -#[test] -fn join() { - let code = " - import * from \"std\" - main { - echo join([\"apple\", \"banana\", \"cherry\"], \", \") - } - "; - test_amber!(code, "apple,banana,cherry") -} - -#[test] -fn trim() { - let code = " - import * from \"std\" - main { - echo trim(\" hello world \") - } - "; - test_amber!(code, "hello world") -} - -#[test] -fn trim_left() { - let code = " - import * from \"std\" - main { - echo trim_left(\" hello world \") - } - "; - test_amber!(code, "hello world ") -} - -#[test] -fn trim_right() { - let code = " - import * from \"std\" - main { - echo trim_right(\" hello world \") - } - "; - test_amber!(code, " hello world") -} - -#[test] -fn lower() { - let code = " - import * from \"std\" - main { - echo lower(\"HELLO WORLD\") - } - "; - test_amber!(code, "hello world") -} - -#[test] -fn upper() { - let code = " - import * from \"std\" - main { - echo upper(\"hello world\") - } - "; - test_amber!(code, "HELLO WORLD") -} - -#[test] -fn len_string() { - let code = " - import * from \"std\" - main { - echo len(\"hello\") - } - "; - test_amber!(code, "5") -} - -#[test] -fn len_list() { - let code = " - import * from \"std\" - main { - echo len([1, 2, 3, 4]) - } - "; - test_amber!(code, "4") -} - -#[test] -fn parse() { - let code = " - import * from \"std\" - main { - echo parse(\"123\")? - } - "; - test_amber!(code, "123") -} - -#[test] -fn chars() { - let code = " - import * from \"std\" - main { - echo chars(\"hello\") - } - "; - test_amber!(code, "h e l l o") -} - -#[test] -fn sum() { - let code = " - import * from \"std\" - main { - echo sum([1, 2, 3, 4]) - } - "; - test_amber!(code, "10") -} - -#[test] -fn has_failed() { - let code = " - import * from \"std\" - main { - if has_failed(\"ls /nonexistent\") { - echo \"Command failed\" - } else { - echo \"Command succeeded\" - } - } - "; - test_amber!(code, "Command failed") -} - -#[test] -fn array_first_index() { - let code = " - import * from \"std\" - main { - echo array_first_index([1, 2, 3, 4], 3) - } - "; - test_amber!(code, "2") -} - -#[test] -fn array_search() { - let code = " - import * from \"std\" - main { - let result = array_search([1, 2, 3, 4, 3], 3) - echo result[0]+result[1] - } - "; - test_amber!(code, "6") -} - -#[test] -fn in_array() { - let code = " - import * from \"std\" - main { - let result = in_array([1, 2, 3, 4, 3], 3) - echo result - } - "; - test_amber!(code, "1") -} - #[test] fn exit() { - let code = " - import * from \"std\" - main { - exit(37) - } - "; + let code = fs::read_to_string("src/tests/stdlib/no_output/exit.ab") + .expect(&format!("Failed to open stdlib/no_output/exit.ab test file")); + let code = compile_code(code); let mut cmd = Command::new("bash") .arg("-c").arg(code) @@ -388,243 +78,15 @@ fn exit() { assert_eq!(cmd.wait().expect("Couldn't wait for bash to execute").code(), Some(37)); } -macro_rules! test_includes { - ($name:ident, $array_declaration:expr, $element:expr, $expected:expr) => { - #[test] - fn $name() { - let array_declaration = $array_declaration.to_string(); - let element = $element.to_string(); - let code = format!(r#" - import * from "std" - - main {{ - let array = {array_declaration} - if includes(array, {element}) {{ - echo "Found" - }} else {{ - echo "Not Found" - }} - }} - "#); - - test_amber!(code, $expected.to_string()) - } - } -} - -test_includes!(includes_empty_text_array, r#"[Text]"#, "\"\"", "Not Found"); -test_includes!(includes_text_array, r#"["apple", "banana", "cherry"]"#, "\"banana\"", "Found"); -test_includes!(includes_exact_match, r#"["apple", "banana cherry"]"#, "\"banana cherry\"", "Found"); -test_includes!(includes_prefix_match, r#"["apple", "banana cherry"]"#, "\"banana\"", "Not Found"); -test_includes!(includes_partial_match_with_expanded_element, r#"["foo", "bar", "baz"]"#, "\"oo ba\"", "Not Found"); -test_includes!(includes_empty_num_array, r#"[Num]"#, 0, "Not Found"); - -#[test] -fn dir_exist() { - let temp_dir = tempdir().expect("Failed to create temporary directory"); - - let code = format!( - " - import * from \"std\" - main {{ - if dir_exist(\"{tmpdir}\") {{ - echo \"Found\" - }} else {{ - echo \"Not Found\" - }} - }} - ", - tmpdir = temp_dir.path().to_str().unwrap() - ); - test_amber!(code, "Found") -} - -#[test] -fn file_exist() { - let temp_dir = tempdir().expect("Failed to create temporary directory"); - let file_path = temp_dir.path().join("test_file.txt"); - - let _file = fs::File::create(&file_path).expect("Failed to create temporary file"); - - let code = format!( - " - import * from \"std\" - main {{ - if file_exist(\"{file_path}\") {{ - echo \"Found\" - }} else {{ - echo \"Not Found\" - }} - }} - ", - file_path = file_path.to_str().unwrap() - ); - test_amber!(code, "Found"); - - fs::remove_file(&file_path).expect("Failed to delete temporary file"); -} - -#[test] -fn lines() { - let code = " - import { lines } from \"std\" - main { - loop line in lines(\"hello\\nworld\") { - echo \"line: \" + line - } - } - "; - test_amber!(code, "line: hello\nline: world") -} - -#[test] -fn is_command() { - let code = " - import { is_command } from \"std\" - main { - if is_command(\"cat\") { - echo \"exist-cat\" - } - - if is_command(\"this_is_not_command_amber\") { - echo \"exist-error\" - } - } - "; - test_amber!(code, "exist-cat") -} - -#[test] -fn create_symbolic_link() { - let code = " - import { create_symbolic_link } from \"std\" - main { - unsafe $touch /tmp/amber-symbolic$ - if create_symbolic_link(\"/tmp/amber-symbolic\", \"/tmp/amber-symbolic-link\") { - echo \"created\" - } else { - echo \"failed\" - } - unsafe $rm /tmp/amber-symbolic$ - unsafe $rm /tmp/amber-symbolic-link$ - } - "; - test_amber!(code, "created") -} - -#[test] -fn create_dir() { - let code = " - import { create_dir, dir_exist } from \"std\" - main { - create_dir(\"/tmp/amber-test\") - if dir_exist(\"/tmp/amber-test\") { - unsafe $rm /tmp/amber-test$ - echo \"created\" - } - } - "; - test_amber!(code, "created") -} - -#[test] -fn make_executable() { - let code = " - import { make_executable } from \"std\" - main { - unsafe $touch /tmp/amber-symbolic$ - if make_executable(\"/tmp/amber-symbolic\") { - echo \"created\" - } - unsafe $rm /tmp/amber-symbolic$ - } - "; - test_amber!(code, "created") -} - -#[test] -fn switch_user_permission() { - // We use `whoami` to get the running user to assign again the same user as permission - let code = " - import { switch_user_permission } from \"std\" - main { - unsafe $touch /tmp/amber-symbolic$ - if switch_user_permission(unsafe $whoami$,\"/tmp/amber-symbolic\") { - echo \"done\" - } - unsafe $rm /tmp/amber-symbolic$ - } - "; - test_amber!(code, "done") -} - #[test] fn download() { let server = std::thread::spawn(http_server); - let code = " - import { download, is_command, exit } from \"std\" - main { - let tempfile = unsafe $mktemp$ - if download(\"http://127.0.0.1:8081/\", tempfile) { - $cat {tempfile}$ failed { - echo \"{tempfile} does not exist!!\" - } - unsafe $rm -f {tempfile}$ - } - } - "; + let code = fs::read_to_string("src/tests/stdlib/no_output/download.ab") + .expect(&format!("Failed to open stdlib/no_output/download.ab test file")); test_amber!(code, "ok"); std::thread::sleep(Duration::from_millis(150)); assert!(server.is_finished(), "Server has not stopped!"); } - -#[test] -fn is_root() { - let code = " - import { is_root } from \"std\" - main { - if not is_root() { - echo \"no\" - } - } - "; - test_amber!(code, "no") -} - -#[test] -fn get_env_var() { - let code = " - import { get_env_var, file_write } from \"std\" - main { - let path = unsafe $mktemp -d /tmp/amber-XXXX$ - unsafe $cd {path}$ - unsafe file_write(\".env\", \"TEST=1\") - if get_env_var(\"TEST\") == \"1\" { - echo \"yes\" - } - unsafe $rm -fr {path}$ - } - "; - test_amber!(code, "yes") -} - -#[test] -fn load_env_file() { - let code = " - import { load_env_file, get_env_var, file_write } from \"std\" - main { - let path = unsafe $mktemp -d /tmp/amber-XXXX$ - unsafe $cd {path}$ - unsafe file_write(\".env\", \"TEST=1\") - load_env_file() - if get_env_var(\"TEST\") == \"1\" { - echo \"yes\" - } - unsafe $rm -fr {path}$ - } - "; - test_amber!(code, "yes") -} diff --git a/src/tests/stdlib/array_first_index.ab b/src/tests/stdlib/array_first_index.ab new file mode 100644 index 00000000..c499d8f5 --- /dev/null +++ b/src/tests/stdlib/array_first_index.ab @@ -0,0 +1,4 @@ +import * from "std" +main { + echo array_first_index([1, 2, 3, 4], 3) +} diff --git a/src/tests/stdlib/array_first_index.output.txt b/src/tests/stdlib/array_first_index.output.txt new file mode 100644 index 00000000..d8263ee9 --- /dev/null +++ b/src/tests/stdlib/array_first_index.output.txt @@ -0,0 +1 @@ +2 \ No newline at end of file diff --git a/src/tests/stdlib/array_search.ab b/src/tests/stdlib/array_search.ab new file mode 100644 index 00000000..f2c8e10e --- /dev/null +++ b/src/tests/stdlib/array_search.ab @@ -0,0 +1,5 @@ +import * from "std" +main { + let result = array_search([1, 2, 3, 4, 3], 3) + echo result[0]+result[1] +} diff --git a/src/tests/stdlib/array_search.output.txt b/src/tests/stdlib/array_search.output.txt new file mode 100644 index 00000000..62f94575 --- /dev/null +++ b/src/tests/stdlib/array_search.output.txt @@ -0,0 +1 @@ +6 \ No newline at end of file diff --git a/src/tests/stdlib/change_owner.ab b/src/tests/stdlib/change_owner.ab new file mode 100644 index 00000000..64103796 --- /dev/null +++ b/src/tests/stdlib/change_owner.ab @@ -0,0 +1,9 @@ +import { change_owner } from "std" +// We use `whoami` to get the running user to assign again the same user as permission +main { + unsafe $touch /tmp/amber-symbolic$ + if change_owner(unsafe $whoami$,"/tmp/amber-symbolic") { + echo "done" + } + unsafe $rm /tmp/amber-symbolic$ +} diff --git a/src/tests/stdlib/change_owner.output.txt b/src/tests/stdlib/change_owner.output.txt new file mode 100644 index 00000000..348ebd94 --- /dev/null +++ b/src/tests/stdlib/change_owner.output.txt @@ -0,0 +1 @@ +done \ No newline at end of file diff --git a/src/tests/stdlib/chars.ab b/src/tests/stdlib/chars.ab new file mode 100644 index 00000000..c4c9aee2 --- /dev/null +++ b/src/tests/stdlib/chars.ab @@ -0,0 +1,4 @@ +import * from "std" +main { + echo chars("hello") +} diff --git a/src/tests/stdlib/chars.output.txt b/src/tests/stdlib/chars.output.txt new file mode 100644 index 00000000..f5397353 --- /dev/null +++ b/src/tests/stdlib/chars.output.txt @@ -0,0 +1 @@ +h e l l o \ No newline at end of file diff --git a/src/tests/stdlib/create_dir.ab b/src/tests/stdlib/create_dir.ab new file mode 100644 index 00000000..442a245b --- /dev/null +++ b/src/tests/stdlib/create_dir.ab @@ -0,0 +1,8 @@ +import { create_dir, dir_exist } from "std" +main { + create_dir("/tmp/amber-test") + if dir_exist("/tmp/amber-test") { + unsafe $rm /tmp/amber-test$ + echo "created" + } +} diff --git a/src/tests/stdlib/create_dir.output.txt b/src/tests/stdlib/create_dir.output.txt new file mode 100644 index 00000000..51ac52fc --- /dev/null +++ b/src/tests/stdlib/create_dir.output.txt @@ -0,0 +1 @@ +created \ No newline at end of file diff --git a/src/tests/stdlib/create_symbolic_link.ab b/src/tests/stdlib/create_symbolic_link.ab new file mode 100644 index 00000000..dfefd580 --- /dev/null +++ b/src/tests/stdlib/create_symbolic_link.ab @@ -0,0 +1,11 @@ +import { create_symbolic_link } from "std" +main { + unsafe $touch /tmp/amber-symbolic$ + if create_symbolic_link("/tmp/amber-symbolic", "/tmp/amber-symbolic-link") { + echo "created" + } else { + echo "failed" + } + unsafe $rm /tmp/amber-symbolic$ + unsafe $rm /tmp/amber-symbolic-link$ +} diff --git a/src/tests/stdlib/create_symbolic_link.output.txt b/src/tests/stdlib/create_symbolic_link.output.txt new file mode 100644 index 00000000..51ac52fc --- /dev/null +++ b/src/tests/stdlib/create_symbolic_link.output.txt @@ -0,0 +1 @@ +created \ No newline at end of file diff --git a/src/tests/stdlib/dir_exist.ab b/src/tests/stdlib/dir_exist.ab new file mode 100644 index 00000000..b5e957f9 --- /dev/null +++ b/src/tests/stdlib/dir_exist.ab @@ -0,0 +1,10 @@ +import * from "std" +main { + let tmpdir = unsafe $mktemp -d /tmp/amber-XXXX$ + if dir_exist(tmpdir) { + echo "Found" + } else { + echo "Not Found" + } + unsafe $rm -fr {tmpdir}$ +} diff --git a/src/tests/stdlib/dir_exist.output.txt b/src/tests/stdlib/dir_exist.output.txt new file mode 100644 index 00000000..85291361 --- /dev/null +++ b/src/tests/stdlib/dir_exist.output.txt @@ -0,0 +1 @@ +Found \ No newline at end of file diff --git a/src/tests/stdlib/file_append.ab b/src/tests/stdlib/file_append.ab new file mode 100644 index 00000000..1ec06216 --- /dev/null +++ b/src/tests/stdlib/file_append.ab @@ -0,0 +1,11 @@ +import * from "std" +main { + let path = unsafe $mktemp -d /tmp/amber-XXXX$ + unsafe $cd {path}$ + unsafe $touch test.txt$ + unsafe file_append("test.txt", "hello") + let f = file_read("test.txt") failed { + echo "Failed" + } + echo f +} diff --git a/src/tests/stdlib/file_append.output.txt b/src/tests/stdlib/file_append.output.txt new file mode 100644 index 00000000..b6fc4c62 --- /dev/null +++ b/src/tests/stdlib/file_append.output.txt @@ -0,0 +1 @@ +hello \ No newline at end of file diff --git a/src/tests/stdlib/file_exist.ab b/src/tests/stdlib/file_exist.ab new file mode 100644 index 00000000..e062a1f7 --- /dev/null +++ b/src/tests/stdlib/file_exist.ab @@ -0,0 +1,12 @@ +import * from "std" +main { + let tmpdir = unsafe $mktemp -d /tmp/amber-XXXX$ + unsafe $cd {tmpdir}$ + unsafe $touch test.txt$ + if file_exist("./test.txt") { + echo "Found" + } else { + echo "Not Found" + } + unsafe $rm -fr {tmpdir}$ +} diff --git a/src/tests/stdlib/file_exist.output.txt b/src/tests/stdlib/file_exist.output.txt new file mode 100644 index 00000000..85291361 --- /dev/null +++ b/src/tests/stdlib/file_exist.output.txt @@ -0,0 +1 @@ +Found \ No newline at end of file diff --git a/src/tests/stdlib/file_read.ab b/src/tests/stdlib/file_read.ab new file mode 100644 index 00000000..7ac24049 --- /dev/null +++ b/src/tests/stdlib/file_read.ab @@ -0,0 +1,10 @@ +import * from "std" +main { + let path = unsafe $mktemp -d /tmp/amber-XXXX$ + unsafe $cd {path}$ + unsafe file_write("test.txt", "hello") + let f = file_read("test.txt") failed { + echo "Failed" + } + echo f +} diff --git a/src/tests/stdlib/file_read.output.txt b/src/tests/stdlib/file_read.output.txt new file mode 100644 index 00000000..b6fc4c62 --- /dev/null +++ b/src/tests/stdlib/file_read.output.txt @@ -0,0 +1 @@ +hello \ No newline at end of file diff --git a/src/tests/stdlib/file_write.ab b/src/tests/stdlib/file_write.ab new file mode 100644 index 00000000..7ac24049 --- /dev/null +++ b/src/tests/stdlib/file_write.ab @@ -0,0 +1,10 @@ +import * from "std" +main { + let path = unsafe $mktemp -d /tmp/amber-XXXX$ + unsafe $cd {path}$ + unsafe file_write("test.txt", "hello") + let f = file_read("test.txt") failed { + echo "Failed" + } + echo f +} diff --git a/src/tests/stdlib/file_write.output.txt b/src/tests/stdlib/file_write.output.txt new file mode 100644 index 00000000..b6fc4c62 --- /dev/null +++ b/src/tests/stdlib/file_write.output.txt @@ -0,0 +1 @@ +hello \ No newline at end of file diff --git a/src/tests/stdlib/get_env_var.ab b/src/tests/stdlib/get_env_var.ab new file mode 100644 index 00000000..04f8ae3d --- /dev/null +++ b/src/tests/stdlib/get_env_var.ab @@ -0,0 +1,10 @@ +import { get_env_var, file_write } from "std" +main { + let path = unsafe $mktemp -d /tmp/amber-XXXX$ + unsafe $cd {path}$ + unsafe file_write(".env", "TEST=1") + if get_env_var("TEST") == "1" { + echo "yes" + } + unsafe $rm -fr {path}$ +} diff --git a/src/tests/stdlib/get_env_var.output.txt b/src/tests/stdlib/get_env_var.output.txt new file mode 100644 index 00000000..396a0ba2 --- /dev/null +++ b/src/tests/stdlib/get_env_var.output.txt @@ -0,0 +1 @@ +yes \ No newline at end of file diff --git a/src/tests/stdlib/has_failed.ab b/src/tests/stdlib/has_failed.ab new file mode 100644 index 00000000..31760ed2 --- /dev/null +++ b/src/tests/stdlib/has_failed.ab @@ -0,0 +1,8 @@ +import * from "std" +main { + if has_failed("ls /nonexistent") { + echo "Command failed" + } else { + echo "Command succeeded" + } +} diff --git a/src/tests/stdlib/has_failed.output.txt b/src/tests/stdlib/has_failed.output.txt new file mode 100644 index 00000000..32944bdc --- /dev/null +++ b/src/tests/stdlib/has_failed.output.txt @@ -0,0 +1 @@ +Command failed \ No newline at end of file diff --git a/src/tests/stdlib/in_array.ab b/src/tests/stdlib/in_array.ab new file mode 100644 index 00000000..cdecfe54 --- /dev/null +++ b/src/tests/stdlib/in_array.ab @@ -0,0 +1,5 @@ +import * from "std" +main { + let result = in_array([1, 2, 3, 4, 3], 3) + echo result +} diff --git a/src/tests/stdlib/in_array.output.txt b/src/tests/stdlib/in_array.output.txt new file mode 100644 index 00000000..56a6051c --- /dev/null +++ b/src/tests/stdlib/in_array.output.txt @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/src/tests/stdlib/includes_empty_num_array.ab b/src/tests/stdlib/includes_empty_num_array.ab new file mode 100644 index 00000000..6ed16acd --- /dev/null +++ b/src/tests/stdlib/includes_empty_num_array.ab @@ -0,0 +1,10 @@ +import * from "std" + +main { + let array = [Num] + if includes(array, 0) { + echo "Found" + } else { + echo "Not Found" + } +} diff --git a/src/tests/stdlib/includes_empty_num_array.output.txt b/src/tests/stdlib/includes_empty_num_array.output.txt new file mode 100644 index 00000000..85373076 --- /dev/null +++ b/src/tests/stdlib/includes_empty_num_array.output.txt @@ -0,0 +1 @@ +Not Found \ No newline at end of file diff --git a/src/tests/stdlib/includes_empty_text_array.ab b/src/tests/stdlib/includes_empty_text_array.ab new file mode 100644 index 00000000..461ec12c --- /dev/null +++ b/src/tests/stdlib/includes_empty_text_array.ab @@ -0,0 +1,10 @@ +import * from "std" + +main { + let array = [Text] + if includes(array, " ") { + echo "Found" + } else { + echo "Not Found" + } +} diff --git a/src/tests/stdlib/includes_empty_text_array.output.txt b/src/tests/stdlib/includes_empty_text_array.output.txt new file mode 100644 index 00000000..85373076 --- /dev/null +++ b/src/tests/stdlib/includes_empty_text_array.output.txt @@ -0,0 +1 @@ +Not Found \ No newline at end of file diff --git a/src/tests/stdlib/includes_exact_match.ab b/src/tests/stdlib/includes_exact_match.ab new file mode 100644 index 00000000..62bd5426 --- /dev/null +++ b/src/tests/stdlib/includes_exact_match.ab @@ -0,0 +1,10 @@ +import * from "std" + +main { + let array = ["apple", "banana cherry"] + if includes(array, "banana cherry") { + echo "Found" + } else { + echo "Not Found" + } +} diff --git a/src/tests/stdlib/includes_exact_match.output.txt b/src/tests/stdlib/includes_exact_match.output.txt new file mode 100644 index 00000000..85291361 --- /dev/null +++ b/src/tests/stdlib/includes_exact_match.output.txt @@ -0,0 +1 @@ +Found \ No newline at end of file diff --git a/src/tests/stdlib/includes_partial_match_with_expanded_element.ab b/src/tests/stdlib/includes_partial_match_with_expanded_element.ab new file mode 100644 index 00000000..3f67485e --- /dev/null +++ b/src/tests/stdlib/includes_partial_match_with_expanded_element.ab @@ -0,0 +1,10 @@ +import * from "std" + +main { + let array = ["foo", "bar", "baz"] + if includes(array, "oo ba") { + echo "Found" + } else { + echo "Not Found" + } +} diff --git a/src/tests/stdlib/includes_partial_match_with_expanded_element.output.txt b/src/tests/stdlib/includes_partial_match_with_expanded_element.output.txt new file mode 100644 index 00000000..85373076 --- /dev/null +++ b/src/tests/stdlib/includes_partial_match_with_expanded_element.output.txt @@ -0,0 +1 @@ +Not Found \ No newline at end of file diff --git a/src/tests/stdlib/includes_prefix_match.ab b/src/tests/stdlib/includes_prefix_match.ab new file mode 100644 index 00000000..4bfcc5c4 --- /dev/null +++ b/src/tests/stdlib/includes_prefix_match.ab @@ -0,0 +1,10 @@ +import * from "std" + +main { + let array = ["apple", "banana cherry"] + if includes(array, "banana") { + echo "Found" + } else { + echo "Not Found" + } +} diff --git a/src/tests/stdlib/includes_prefix_match.output.txt b/src/tests/stdlib/includes_prefix_match.output.txt new file mode 100644 index 00000000..85373076 --- /dev/null +++ b/src/tests/stdlib/includes_prefix_match.output.txt @@ -0,0 +1 @@ +Not Found \ No newline at end of file diff --git a/src/tests/stdlib/includes_text_array.ab b/src/tests/stdlib/includes_text_array.ab new file mode 100644 index 00000000..f5f8f776 --- /dev/null +++ b/src/tests/stdlib/includes_text_array.ab @@ -0,0 +1,10 @@ +import * from "std" + +main { + let array = ["apple", "banana", "cherry"] + if includes(array, "banana") { + echo "Found" + } else { + echo "Not Found" + } +} diff --git a/src/tests/stdlib/includes_text_array.output.txt b/src/tests/stdlib/includes_text_array.output.txt new file mode 100644 index 00000000..85291361 --- /dev/null +++ b/src/tests/stdlib/includes_text_array.output.txt @@ -0,0 +1 @@ +Found \ No newline at end of file diff --git a/src/tests/stdlib/is_command.ab b/src/tests/stdlib/is_command.ab new file mode 100644 index 00000000..f68ef7c8 --- /dev/null +++ b/src/tests/stdlib/is_command.ab @@ -0,0 +1,10 @@ +import { is_command } from "std" +main { + if is_command("cat") { + echo "exist-cat" + } + + if is_command("this_is_not_command_amber") { + echo "exist-error" + } +} diff --git a/src/tests/stdlib/is_command.output.txt b/src/tests/stdlib/is_command.output.txt new file mode 100644 index 00000000..3a86db11 --- /dev/null +++ b/src/tests/stdlib/is_command.output.txt @@ -0,0 +1 @@ +exist-cat \ No newline at end of file diff --git a/src/tests/stdlib/is_root.ab b/src/tests/stdlib/is_root.ab new file mode 100644 index 00000000..b0196fe7 --- /dev/null +++ b/src/tests/stdlib/is_root.ab @@ -0,0 +1,6 @@ +import { is_root } from "std" +main { + if not is_root() { + echo "no" + } +} diff --git a/src/tests/stdlib/is_root.output.txt b/src/tests/stdlib/is_root.output.txt new file mode 100644 index 00000000..54299a48 --- /dev/null +++ b/src/tests/stdlib/is_root.output.txt @@ -0,0 +1 @@ +no \ No newline at end of file diff --git a/src/tests/stdlib/join.ab b/src/tests/stdlib/join.ab new file mode 100644 index 00000000..63844933 --- /dev/null +++ b/src/tests/stdlib/join.ab @@ -0,0 +1,4 @@ +import * from "std" +main { + echo join(["apple", "banana", "cherry"], ", ") +} diff --git a/src/tests/stdlib/join.output.txt b/src/tests/stdlib/join.output.txt new file mode 100644 index 00000000..8099389e --- /dev/null +++ b/src/tests/stdlib/join.output.txt @@ -0,0 +1 @@ +apple,banana,cherry \ No newline at end of file diff --git a/src/tests/stdlib/len_list.ab b/src/tests/stdlib/len_list.ab new file mode 100644 index 00000000..a628f47d --- /dev/null +++ b/src/tests/stdlib/len_list.ab @@ -0,0 +1,4 @@ +import * from "std" +main { + echo len([1, 2, 3, 4]) +} diff --git a/src/tests/stdlib/len_list.output.txt b/src/tests/stdlib/len_list.output.txt new file mode 100644 index 00000000..bf0d87ab --- /dev/null +++ b/src/tests/stdlib/len_list.output.txt @@ -0,0 +1 @@ +4 \ No newline at end of file diff --git a/src/tests/stdlib/len_string.ab b/src/tests/stdlib/len_string.ab new file mode 100644 index 00000000..f4ba2620 --- /dev/null +++ b/src/tests/stdlib/len_string.ab @@ -0,0 +1,4 @@ +import * from "std" +main { + echo len("hello") +} diff --git a/src/tests/stdlib/len_string.output.txt b/src/tests/stdlib/len_string.output.txt new file mode 100644 index 00000000..7813681f --- /dev/null +++ b/src/tests/stdlib/len_string.output.txt @@ -0,0 +1 @@ +5 \ No newline at end of file diff --git a/src/tests/stdlib/lines.ab b/src/tests/stdlib/lines.ab new file mode 100644 index 00000000..9a581899 --- /dev/null +++ b/src/tests/stdlib/lines.ab @@ -0,0 +1,6 @@ +import { lines } from "std" +main { + loop line in lines("hello\nworld") { + echo "line: " + line + } +} diff --git a/src/tests/stdlib/lines.output.txt b/src/tests/stdlib/lines.output.txt new file mode 100644 index 00000000..e3b070da --- /dev/null +++ b/src/tests/stdlib/lines.output.txt @@ -0,0 +1,2 @@ +line: hello +line: world \ No newline at end of file diff --git a/src/tests/stdlib/load_env_file.ab b/src/tests/stdlib/load_env_file.ab new file mode 100644 index 00000000..dc8ea90a --- /dev/null +++ b/src/tests/stdlib/load_env_file.ab @@ -0,0 +1,11 @@ +import { load_env_file, get_env_var, file_write } from "std" +main { + let path = unsafe $mktemp -d /tmp/amber-XXXX$ + unsafe $cd {path}$ + unsafe file_write(".env", "TEST=1") + load_env_file() + if get_env_var("TEST") == "1" { + echo "yes" + } + unsafe $rm -fr {path}$ +} diff --git a/src/tests/stdlib/load_env_file.output.txt b/src/tests/stdlib/load_env_file.output.txt new file mode 100644 index 00000000..396a0ba2 --- /dev/null +++ b/src/tests/stdlib/load_env_file.output.txt @@ -0,0 +1 @@ +yes \ No newline at end of file diff --git a/src/tests/stdlib/lower.ab b/src/tests/stdlib/lower.ab new file mode 100644 index 00000000..0fa92981 --- /dev/null +++ b/src/tests/stdlib/lower.ab @@ -0,0 +1,4 @@ +import * from "std" +main { + echo lower("HELLO WORLD") +} diff --git a/src/tests/stdlib/lower.output.txt b/src/tests/stdlib/lower.output.txt new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/src/tests/stdlib/lower.output.txt @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/src/tests/stdlib/make_executable.ab b/src/tests/stdlib/make_executable.ab new file mode 100644 index 00000000..6fa6ef74 --- /dev/null +++ b/src/tests/stdlib/make_executable.ab @@ -0,0 +1,8 @@ +import { make_executable } from "std" +main { + unsafe $touch /tmp/amber-symbolic$ + if make_executable("/tmp/amber-symbolic") { + echo "created" + } + unsafe $rm /tmp/amber-symbolic$ +} diff --git a/src/tests/stdlib/make_executable.output.txt b/src/tests/stdlib/make_executable.output.txt new file mode 100644 index 00000000..51ac52fc --- /dev/null +++ b/src/tests/stdlib/make_executable.output.txt @@ -0,0 +1 @@ +created \ No newline at end of file diff --git a/src/tests/stdlib/no_output/download.ab b/src/tests/stdlib/no_output/download.ab new file mode 100644 index 00000000..a1b24634 --- /dev/null +++ b/src/tests/stdlib/no_output/download.ab @@ -0,0 +1,11 @@ +import * from "std" +main { + let tmpdir = unsafe $mktemp -d /tmp/amber-XXXX$ + unsafe $cd {tmpdir}$ + if download("http://127.0.0.1:8081/", "./test.txt") { + if file_exist("./test.txt") { + echo "ok" + } + } + unsafe $rm -fr {tmpdir}$ +} \ No newline at end of file diff --git a/src/tests/stdlib/no_output/exit.ab b/src/tests/stdlib/no_output/exit.ab new file mode 100644 index 00000000..45db9d4d --- /dev/null +++ b/src/tests/stdlib/no_output/exit.ab @@ -0,0 +1,4 @@ +import * from "std" +main { + exit(37) +} diff --git a/src/tests/stdlib/no_output/input.ab b/src/tests/stdlib/no_output/input.ab new file mode 100644 index 00000000..640b0c2f --- /dev/null +++ b/src/tests/stdlib/no_output/input.ab @@ -0,0 +1,5 @@ +import * from "std" +main { + let name = input("Please enter your name:") + echo "Hello, " + name +} diff --git a/src/tests/stdlib/parse.ab b/src/tests/stdlib/parse.ab new file mode 100644 index 00000000..a546ce96 --- /dev/null +++ b/src/tests/stdlib/parse.ab @@ -0,0 +1,4 @@ +import * from "std" +main { + echo parse("123")? +} diff --git a/src/tests/stdlib/parse.output.txt b/src/tests/stdlib/parse.output.txt new file mode 100644 index 00000000..d800886d --- /dev/null +++ b/src/tests/stdlib/parse.output.txt @@ -0,0 +1 @@ +123 \ No newline at end of file diff --git a/src/tests/stdlib/replace.ab b/src/tests/stdlib/replace.ab new file mode 100644 index 00000000..b493e7a3 --- /dev/null +++ b/src/tests/stdlib/replace.ab @@ -0,0 +1,4 @@ +import * from "std" +main { + echo replace("banana banana", "banana", "apple") +} diff --git a/src/tests/stdlib/replace.output.txt b/src/tests/stdlib/replace.output.txt new file mode 100644 index 00000000..51b4b1ff --- /dev/null +++ b/src/tests/stdlib/replace.output.txt @@ -0,0 +1 @@ +apple apple \ No newline at end of file diff --git a/src/tests/stdlib/replace_once.ab b/src/tests/stdlib/replace_once.ab new file mode 100644 index 00000000..d7b41558 --- /dev/null +++ b/src/tests/stdlib/replace_once.ab @@ -0,0 +1,4 @@ +import * from "std" +main { + echo replace_once("hello world!", "world", "Amber") +} diff --git a/src/tests/stdlib/replace_once.output.txt b/src/tests/stdlib/replace_once.output.txt new file mode 100644 index 00000000..53133538 --- /dev/null +++ b/src/tests/stdlib/replace_once.output.txt @@ -0,0 +1 @@ +hello Amber! \ No newline at end of file diff --git a/src/tests/stdlib/replace_regex.ab b/src/tests/stdlib/replace_regex.ab new file mode 100644 index 00000000..6577c20e --- /dev/null +++ b/src/tests/stdlib/replace_regex.ab @@ -0,0 +1,4 @@ +import * from "std" +main { + echo replace_regex("abc123def", "[0-9][0-9]*", "456") +} diff --git a/src/tests/stdlib/replace_regex.output.txt b/src/tests/stdlib/replace_regex.output.txt new file mode 100644 index 00000000..1a577554 --- /dev/null +++ b/src/tests/stdlib/replace_regex.output.txt @@ -0,0 +1 @@ +abc456def \ No newline at end of file diff --git a/src/tests/stdlib/split.ab b/src/tests/stdlib/split.ab new file mode 100644 index 00000000..ee0fd73b --- /dev/null +++ b/src/tests/stdlib/split.ab @@ -0,0 +1,5 @@ +import * from "std" +main { + let array = split("apple,banana,cherry", ",") + echo array[1] +} diff --git a/src/tests/stdlib/split.output.txt b/src/tests/stdlib/split.output.txt new file mode 100644 index 00000000..570a66f5 --- /dev/null +++ b/src/tests/stdlib/split.output.txt @@ -0,0 +1 @@ +banana \ No newline at end of file diff --git a/src/tests/stdlib/split_multiline.ab b/src/tests/stdlib/split_multiline.ab new file mode 100644 index 00000000..65bd1dc7 --- /dev/null +++ b/src/tests/stdlib/split_multiline.ab @@ -0,0 +1,5 @@ +import * from "std" +main { + let array = split("apple,ban\nana,cherry", ",") + echo array +} diff --git a/src/tests/stdlib/split_multiline.output.txt b/src/tests/stdlib/split_multiline.output.txt new file mode 100644 index 00000000..64483cc4 --- /dev/null +++ b/src/tests/stdlib/split_multiline.output.txt @@ -0,0 +1,2 @@ +apple ban +ana cherry \ No newline at end of file diff --git a/src/tests/stdlib/sum.ab b/src/tests/stdlib/sum.ab new file mode 100644 index 00000000..fc05a891 --- /dev/null +++ b/src/tests/stdlib/sum.ab @@ -0,0 +1,4 @@ +import * from "std" +main { + echo sum([1, 2, 3, 4]) +} diff --git a/src/tests/stdlib/sum.output.txt b/src/tests/stdlib/sum.output.txt new file mode 100644 index 00000000..9a037142 --- /dev/null +++ b/src/tests/stdlib/sum.output.txt @@ -0,0 +1 @@ +10 \ No newline at end of file diff --git a/src/tests/stdlib/trim.ab b/src/tests/stdlib/trim.ab new file mode 100644 index 00000000..b15188eb --- /dev/null +++ b/src/tests/stdlib/trim.ab @@ -0,0 +1,4 @@ +import * from "std" +main { + echo trim(" hello world ") +} diff --git a/src/tests/stdlib/trim.output.txt b/src/tests/stdlib/trim.output.txt new file mode 100644 index 00000000..154904bd --- /dev/null +++ b/src/tests/stdlib/trim.output.txt @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/src/tests/stdlib/trim_left.ab b/src/tests/stdlib/trim_left.ab new file mode 100644 index 00000000..28afcf55 --- /dev/null +++ b/src/tests/stdlib/trim_left.ab @@ -0,0 +1,5 @@ + import * from "std" + main { + echo trim_left(" hello world ") +} + diff --git a/src/tests/stdlib/trim_left.output.txt b/src/tests/stdlib/trim_left.output.txt new file mode 100644 index 00000000..95ee4965 --- /dev/null +++ b/src/tests/stdlib/trim_left.output.txt @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/src/tests/stdlib/trim_right.ab b/src/tests/stdlib/trim_right.ab new file mode 100644 index 00000000..49540e06 --- /dev/null +++ b/src/tests/stdlib/trim_right.ab @@ -0,0 +1,4 @@ +import * from "std" +main { + echo trim_right(" hello world ") +} diff --git a/src/tests/stdlib/trim_right.output.txt b/src/tests/stdlib/trim_right.output.txt new file mode 100644 index 00000000..3f3ffdd8 --- /dev/null +++ b/src/tests/stdlib/trim_right.output.txt @@ -0,0 +1 @@ + hello world \ No newline at end of file diff --git a/src/tests/stdlib/upper.ab b/src/tests/stdlib/upper.ab new file mode 100644 index 00000000..deef4955 --- /dev/null +++ b/src/tests/stdlib/upper.ab @@ -0,0 +1,4 @@ +import * from "std" +main { + echo upper("hello world") +} diff --git a/src/tests/stdlib/upper.output.txt b/src/tests/stdlib/upper.output.txt new file mode 100644 index 00000000..1fcc4abb --- /dev/null +++ b/src/tests/stdlib/upper.output.txt @@ -0,0 +1 @@ +HELLO WORLD \ No newline at end of file