diff --git a/ci/check_all_exposed_funs_tested.roc b/ci/check_all_exposed_funs_tested.roc index 412c524..704589d 100644 --- a/ci/check_all_exposed_funs_tested.roc +++ b/ci/check_all_exposed_funs_tested.roc @@ -22,7 +22,7 @@ main! = |_args| # Check if ripgrep is installed _ = Cmd.exec!("rg", ["--version"])? - cwd = Env.cwd!({}) ? |err| FailedToGetCwd(err) + cwd = Env.cwd!({}) ? FailedToGetCwd Stdout.line!("Current working directory: ${Path.display(cwd)}")? path_to_platform_main = "platform/main.roc" @@ -87,7 +87,7 @@ is_function_unused! = |module_name, function_name| search_dirs = ["examples", "tests"] # Check current working directory - cwd = Env.cwd!({}) ? |err| FailedToGetCwd2(err) + cwd = Env.cwd!({}) ? FailedToGetCwd2 # Check if directories exist List.for_each_try!( diff --git a/examples/todos.roc b/examples/todos.roc index 4321fcb..583ebcf 100644 --- a/examples/todos.roc +++ b/examples/todos.roc @@ -161,7 +161,7 @@ exec_transaction! = |{ begin_stmt, rollback_stmt, end_stmt }, transaction!| bindings: [], }, ) - ? |err| FailedToBeginTransaction(err) + ? FailedToBeginTransaction end_transaction! = |res| when res is @@ -172,7 +172,7 @@ exec_transaction! = |{ begin_stmt, rollback_stmt, end_stmt }, transaction!| bindings: [], }, ) - ? |err| FailedToEndTransaction(err) + ? FailedToEndTransaction Ok(v) @@ -190,7 +190,7 @@ exec_transaction! = |{ begin_stmt, rollback_stmt, end_stmt }, transaction!| bindings: [], }, ) - ? |err| FailedToRollbackTransaction(err) + ? FailedToRollbackTransaction Err(e) diff --git a/tests/dir-test.roc b/tests/dir-test.roc index 4339b86..59d9d92 100644 --- a/tests/dir-test.roc +++ b/tests/dir-test.roc @@ -50,7 +50,7 @@ test_dir_create! = |{}| # Test creating a single directory test_dir_name = "test_dir_create" - Dir.create!(test_dir_name) ? |err| DirCreateFailed(err) + Dir.create!(test_dir_name) ? DirCreateFailed # Verify directory exists using ls ls_output = @@ -301,7 +301,7 @@ cleanup_test_dirs! = |dirs_requirement| when dirs_requirement is DirsNeedToExist -> - delete_result ? |err| DirDeletionFailed(err) + delete_result ? DirDeletionFailed DirsMaybeExist -> Ok({})? diff --git a/tests/file.roc b/tests/file.roc index 8e1b308..c7aa19b 100644 --- a/tests/file.roc +++ b/tests/file.roc @@ -230,7 +230,7 @@ test_file_exists! = |{}| filename = "test_exists.txt" File.write_utf8!("", filename)? - test_file_exists = File.exists!(filename) ? |err| FileExistsCheckFailed(err) + test_file_exists = File.exists!(filename) ? FileExistsCheckFailed if test_file_exists then Stdout.line!("✓ File.exists! returns true for a file that exists")? @@ -240,7 +240,7 @@ test_file_exists! = |{}| # Test that a file that does not exist returns false File.delete!(filename)? - test_file_exists_after_delete = File.exists!(filename) ? |err| FileExistsCheckAfterDeleteFailed(err) + test_file_exists_after_delete = File.exists!(filename) ? FileExistsCheckAfterDeleteFailed if test_file_exists_after_delete then Stderr.line!("✗ File.exists! returned true for a file that does not exist")? @@ -300,7 +300,7 @@ cleanup_test_files! = |files_requirement| when files_requirement is FilesNeedToExist -> - delete_result ? |err| FileDeletionFailed(err) + delete_result ? FileDeletionFailed FilesMaybeExist -> Ok({})? diff --git a/tests/path-test.roc b/tests/path-test.roc index 7bd980b..40e52ba 100644 --- a/tests/path-test.roc +++ b/tests/path-test.roc @@ -160,7 +160,7 @@ test_file_operations! = |{}| # Verify file exists before deletion _ = Cmd.exec!("test", ["-e", "test_to_delete.txt"])? - Path.delete!(delete_path) ? |err| DeleteFailed(err) + Path.delete!(delete_path) ? DeleteFailed # Verify file is gone after deletion exists_after_res = Cmd.exec!("test", ["-e", "test_to_delete.txt"]) @@ -342,7 +342,7 @@ test_path_rename! = |{}| new_path = Path.from_str("test_path_rename_new.txt") test_file_content = "Content for rename test." - Path.write_utf8!(test_file_content, original_path) ? |err| WriteOriginalFailed(err) + Path.write_utf8!(test_file_content, original_path) ? WriteOriginalFailed # Rename the file when Path.rename!(original_path, new_path) is @@ -357,12 +357,12 @@ test_path_rename! = |{}| else Stdout.line!("✓ Original file no longer exists")? - new_file_exists = Path.is_file!(new_path) ? |err| NewIsFileFailed(err) + new_file_exists = Path.is_file!(new_path) ? NewIsFileFailed if new_file_exists then Stdout.line!("✓ Renamed file exists")? - content = Path.read_utf8!(new_path) ? |err| NewFileReadFailed(err) + content = Path.read_utf8!(new_path) ? NewFileReadFailed if content == test_file_content then Stdout.line!("✓ Renamed file has correct content") @@ -382,7 +382,7 @@ test_path_exists! = |{}| filename = Path.from_str("test_path_exists.txt") Path.write_utf8!("This file exists", filename)? - file_exists = Path.exists!(filename) ? |err| PathExistsCheckFailed(err) + file_exists = Path.exists!(filename) ? PathExistsCheckFailed if file_exists then Stdout.line!("✓ Path.exists! returns true for a file that exists")? @@ -392,7 +392,7 @@ test_path_exists! = |{}| # Test that a file that does not exist returns false Path.delete!(filename)? - file_exists_after_delete = Path.exists!(filename) ? |err| PathExistsCheckAfterDeleteFailed(err) + file_exists_after_delete = Path.exists!(filename) ? PathExistsCheckAfterDeleteFailed if file_exists_after_delete then Stderr.line!("✗ Path.exists! returned true for a file that does not exist")? @@ -422,23 +422,23 @@ test_is_sym_link! = |{}| ln_dir_result = Cmd.new("ln") |> Cmd.args(["-s", "test_directory", "test_symlink_to_dir"]) |> Cmd.exec_output!() # Test is_sym_link on regular file - regular_is_symlink = Path.is_sym_link!(regular_file) ? |err| RegularFileSymlinkCheckFailed(err) + regular_is_symlink = Path.is_sym_link!(regular_file) ? RegularFileSymlinkCheckFailed # Test is_sym_link on directory - dir_is_symlink = Path.is_sym_link!(test_dir) ? |err| DirSymlinkCheckFailed(err) + dir_is_symlink = Path.is_sym_link!(test_dir) ? DirSymlinkCheckFailed # Test is_sym_link on symbolic links (if creation succeeded) file_link_is_symlink = when ln_file_result is Ok(_) -> - Path.is_sym_link!(link_to_file) ? |err| FileLinkSymlinkCheckFailed(err) + Path.is_sym_link!(link_to_file) ? FileLinkSymlinkCheckFailed Err(_) -> Bool.false dir_link_is_symlink = when ln_dir_result is Ok(_) -> - Path.is_sym_link!(link_to_dir) ? |err| DirLinkSymlinkCheckFailed(err) + Path.is_sym_link!(link_to_dir) ? DirLinkSymlinkCheckFailed Err(_) -> Bool.false @@ -480,16 +480,16 @@ test_path_type! = |{}| ln_result = Cmd.new("ln") |> Cmd.args(["-s", "test_type_file.txt", "test_type_symlink.txt"]) |> Cmd.exec_output!() # Test type on regular file - file_type = Path.type!(regular_file) ? |err| FileTypeCheckFailed(err) + file_type = Path.type!(regular_file) ? FileTypeCheckFailed # Test type on directory - dir_type = Path.type!(test_dir) ? |err| DirTypeCheckFailed(err) + dir_type = Path.type!(test_dir) ? DirTypeCheckFailed # Test type on symbolic link (if creation succeeded) symlink_type = when ln_result is Ok(_) -> - Path.type!(symlink_path) ? |err| SymlinkTypeCheckFailed(err) + Path.type!(symlink_path) ? SymlinkTypeCheckFailed Err(_) -> IsFile @@ -542,7 +542,7 @@ cleanup_test_files! = |files_requirement| when files_requirement is FilesNeedToExist -> - delete_result ? |err| PathDeletionFailed(err) + delete_result ? PathDeletionFailed FilesMaybeExist -> Ok({})? diff --git a/tests/sqlite-test.roc b/tests/sqlite-test.roc index b43c891..27907c3 100644 --- a/tests/sqlite-test.roc +++ b/tests/sqlite-test.roc @@ -52,7 +52,7 @@ run_tests! = |{}| col_nullable_f64: Sqlite.nullable_f64("col_nullable_f64"), col_nullable_f32: Sqlite.nullable_f32("col_nullable_f32"), }, - }) ? |err| QuerManyFailed(err) + }) ? QuerManyFailed rows_texts_str = all_rows @@ -68,7 +68,7 @@ run_tests! = |{}| query: "SELECT COUNT(*) as \"count\" FROM test;", bindings: [], row: Sqlite.u64("count"), - }) ? |err| QueryCountFailed(err) + }) ? QueryCountFailed Stdout.line!("Row count: ${Num.to_str(count)}")? @@ -78,13 +78,13 @@ run_tests! = |{}| prepared_count_query = Sqlite.prepare!({ path: db_path, query: "SELECT COUNT(*) as \"count\" FROM test;", - }) ? |err| PrepareFailed(err) + }) ? PrepareFailed count_prepared = Sqlite.query_prepared!({ stmt: prepared_count_query, bindings: [], row: Sqlite.u64("count"), - }) ? |err| QueryPreparedFailed(err) + }) ? QueryPreparedFailed Stdout.line!("Row count (prepared): ${Num.to_str(count_prepared)}")? @@ -94,7 +94,7 @@ run_tests! = |{}| prepared_update = Sqlite.prepare!({ path: db_path, query: "UPDATE test SET col_text = :col_text WHERE id = :id;", - }) ? |err| PreparedUpdateFailed(err) + }) ? PreparedUpdateFailed Sqlite.execute_prepared!({ stmt: prepared_update, @@ -102,7 +102,7 @@ run_tests! = |{}| { name: ":id", value: Integer(1) }, { name: ":col_text", value: String("Updated text 1") }, ], - }) ? |err| ExecutePreparedFailed(err) + }) ? ExecutePreparedFailed Sqlite.execute_prepared!({ stmt: prepared_update, @@ -110,7 +110,7 @@ run_tests! = |{}| { name: ":id", value: Integer(2) }, { name: ":col_text", value: String("Updated text 2") }, ], - }) ? |err| ExecutePrepared2Failed(err) + }) ? ExecutePrepared2Failed # Check if the updates were successful updated_rows = Sqlite.query_many!({ @@ -118,7 +118,7 @@ run_tests! = |{}| query: "SELECT COL_TEXT FROM test;", bindings: [], rows: Sqlite.str("col_text"), - }) ? |err| QueryUpdatedRowsFailed(err) + }) ? QueryUpdatedRowsFailed Stdout.line!("Updated rows: ${Inspect.to_str(updated_rows)}")? @@ -129,7 +129,7 @@ run_tests! = |{}| { name: ":id", value: Integer(1) }, { name: ":col_text", value: String("example text") }, ], - }) ? |err| ExecutePrepared3Failed(err) + }) ? ExecutePrepared3Failed Sqlite.execute_prepared!({ stmt: prepared_update, @@ -137,7 +137,7 @@ run_tests! = |{}| { name: ":id", value: Integer(2) }, { name: ":col_text", value: String("sample text") }, ], - }) ? |err| ExecutePrepared4Failed(err) + }) ? ExecutePrepared4Failed # Test tagged_value tagged_value_test = Sqlite.query_many!({ @@ -146,7 +146,7 @@ run_tests! = |{}| bindings: [], # This uses the record builder syntax: https://www.roc-lang.org/examples/RecordBuilder/README.html rows: Sqlite.tagged_value("col_text"), - }) ? |err| QueryMany2Failed(err) + }) ? QueryMany2Failed Stdout.line!("Tagged value test: ${Inspect.to_str(tagged_value_test)}")? diff --git a/tests/tcp.roc b/tests/tcp.roc index 18950e6..a8eefd2 100644 --- a/tests/tcp.roc +++ b/tests/tcp.roc @@ -64,8 +64,8 @@ test_tcp_functions! = |stream| do_not_read_bytes = [100, 111, 32, 110, 111, 116, 32, 114, 101, 97, 100, 32, 112, 97, 115, 116, 32, 109, 101, 65] # "do not read past meA" in bytes Tcp.write!(stream, do_not_read_bytes)? - nineteen_bytes = Tcp.read_up_to!(stream, 19) ? |err| FailedReadUpTo(err) - nineteen_bytes_as_str = Str.from_utf8(nineteen_bytes) ? |err| ReadUpToFromUtf8(err) + nineteen_bytes = Tcp.read_up_to!(stream, 19) ? FailedReadUpTo + nineteen_bytes_as_str = Str.from_utf8(nineteen_bytes) ? ReadUpToFromUtf8 Stdout.line!( """ @@ -77,8 +77,8 @@ test_tcp_functions! = |stream| )? Tcp.write_utf8!(stream, "BC")? - three_bytes = Tcp.read_exactly!(stream, 3) ? |err| FailedReadExactly(err) - three_bytes_as_str = Str.from_utf8(three_bytes) ? |err| ReadExactlyFromUtf8(err) + three_bytes = Tcp.read_exactly!(stream, 3) ? FailedReadExactly + three_bytes_as_str = Str.from_utf8(three_bytes) ? ReadExactlyFromUtf8 Stdout.line!( """ @@ -90,8 +90,8 @@ test_tcp_functions! = |stream| )? Tcp.write_utf8!(stream, "Line1\nLine2\n")? - bytes_until = Tcp.read_until!(stream, '\n') ? |err| FailedReadUntil(err) - bytes_until_as_str = Str.from_utf8(bytes_until) ? |err| ReadUntilFromUtf8(err) + bytes_until = Tcp.read_until!(stream, '\n') ? FailedReadUntil + bytes_until_as_str = Str.from_utf8(bytes_until) ? ReadUntilFromUtf8 Stdout.line!("Tcp.read_until yielded: '${bytes_until_as_str}'\n")?