From 5e73815a90614155818d5095a7105b34887b10c5 Mon Sep 17 00:00:00 2001 From: "Md. Almas Ali" Date: Sun, 26 May 2024 19:58:54 +0600 Subject: [PATCH] tests: updated tests for raise and radiation features. --- tests/radiation-modules.rn | 16 ++++++++++++++++ tests/radiation-modules.rn.json | 1 + tests/raise.rn.json | 2 +- tests/raise2.rn.json | 2 +- tests/raise3.rn.json | 2 +- 5 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 tests/radiation-modules.rn create mode 100644 tests/radiation-modules.rn.json diff --git a/tests/radiation-modules.rn b/tests/radiation-modules.rn new file mode 100644 index 0000000..e895a8e --- /dev/null +++ b/tests/radiation-modules.rn @@ -0,0 +1,16 @@ +import radiation + +errors = radiation.errors + +# print(radiation.errors[0]) + +# print(errors[0]("ValueError: " + "This is a test error message")) + +assert arr_len(errors) == 17, "Error length is not 17" + +try { + raise errors[1]("This is error message!") +} +catch as err { + print(err) +} \ No newline at end of file diff --git a/tests/radiation-modules.rn.json b/tests/radiation-modules.rn.json new file mode 100644 index 0000000..4d6393a --- /dev/null +++ b/tests/radiation-modules.rn.json @@ -0,0 +1 @@ +{"code": 0, "stdout": "TypeError: This is error message!\n", "stderr": ""} \ No newline at end of file diff --git a/tests/raise.rn.json b/tests/raise.rn.json index 0cab28b..d0217b7 100644 --- a/tests/raise.rn.json +++ b/tests/raise.rn.json @@ -1 +1 @@ -{"code": 1, "stdout": "test1\ntest2\n\u001b[38;5;208mRadiation (most recent call last):\n\u001b[0m File \u001b[38;5;117mtests/raise.rn\u001b[0m, line \u001b[38;5;117m7\u001b[0m\n\u001b[1m\u001b[31mArgError\u001b[0m: \u001b[38;5;203mArgument `arg1` not found\u001b[0m\n\nraise \u001b[1m\u001b[31mArgError(\"arg1\"\u001b[0m)\n \u001b[1m\u001b[31m^^^^^^^^^^^^^^^\u001b[0m\n", "stderr": ""} \ No newline at end of file +{"code": 1, "stdout": "test1\ntest2\n\u001b[38;5;208mRadiation (most recent call last):\n\u001b[0m File \u001b[38;5;117mtests/raise.rn\u001b[0m, line \u001b[38;5;117m7\u001b[0m\n\u001b[1m\u001b[31mArgError\u001b[0m: \u001b[38;5;203mArgument `arg1` not found\u001b[0m\n\nraise\u001b[1m\u001b[31m ArgError(\"arg1\"\u001b[0m)\n \u001b[1m\u001b[31m^^^^^^^^^^^^^^^\u001b[0m\n", "stderr": ""} \ No newline at end of file diff --git a/tests/raise2.rn.json b/tests/raise2.rn.json index 4378096..6db5976 100644 --- a/tests/raise2.rn.json +++ b/tests/raise2.rn.json @@ -1 +1 @@ -{"code": 1, "stdout": "\u001b[38;5;208mRadiation (most recent call last):\n\u001b[0m File \u001b[38;5;117mtests/raise2.rn\u001b[0m, line \u001b[38;5;117m4\u001b[0m\n\u001b[1m\u001b[31mSomeError\u001b[0m: \u001b[38;5;203mThe massage: AAAAAAAAAAAAAAAAA\u001b[0m\n\nraise \u001b[1m\u001b[31mraise2_lib.SomeError(\"AAAAAAAAAAAAAAAAA\"\u001b[0m)\n \u001b[1m\u001b[31m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", "stderr": ""} \ No newline at end of file +{"code": 1, "stdout": "\u001b[38;5;208mRadiation (most recent call last):\n\u001b[0m File \u001b[38;5;117mtests/raise2.rn\u001b[0m, line \u001b[38;5;117m4\u001b[0m\n\u001b[1m\u001b[31mSomeError\u001b[0m: \u001b[38;5;203mThe massage: AAAAAAAAAAAAAAAAA\u001b[0m\n\nraise\u001b[1m\u001b[31m raise2_lib.SomeError(\"AAAAAAAAAAAAAAAAA\"\u001b[0m)\n \u001b[1m\u001b[31m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", "stderr": ""} \ No newline at end of file diff --git a/tests/raise3.rn.json b/tests/raise3.rn.json index 1106449..a6828a7 100644 --- a/tests/raise3.rn.json +++ b/tests/raise3.rn.json @@ -1 +1 @@ -{"code": 1, "stdout": "\u001b[38;5;208mRadiation (most recent call last):\n\u001b[0m File \u001b[38;5;117mtests/raise3.rn\u001b[0m, line \u001b[38;5;117m4\u001b[0m\n\u001b[1m\u001b[31mSomeError\u001b[0m: \u001b[38;5;203mThe massage: default massage\u001b[0m\n\nraise \u001b[1m\u001b[31mraise2_lib.SomeError\u001b[0m\n \u001b[1m\u001b[31m^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", "stderr": ""} \ No newline at end of file +{"code": 1, "stdout": "\u001b[38;5;208mRadiation (most recent call last):\n\u001b[0m File \u001b[38;5;117mtests/raise3.rn\u001b[0m, line \u001b[38;5;117m4\u001b[0m\n\u001b[1m\u001b[31mSomeError\u001b[0m: \u001b[38;5;203mThe massage: default massage\u001b[0m\n\nraise\u001b[1m\u001b[31m raise2_lib.SomeError\u001b[0m\n \u001b[1m\u001b[31m^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", "stderr": ""} \ No newline at end of file