public inbox for ~johnnyrichard/olang-devel@lists.sr.ht
 help / color / mirror / code / Atom feed
From: Carlos Maniero <carlos@maniero.me>
To: ~johnnyrichard/olang-devel@lists.sr.ht
Cc: Carlos Maniero <carlos@maniero.me>
Subject: [PATCH olang 3/4] tests: include integration tests for function parser errors
Date: Sun, 12 May 2024 11:30:32 -0300	[thread overview]
Message-ID: <20240512143033.229961-4-carlos@maniero.me> (raw)
In-Reply-To: <20240512143033.229961-1-carlos@maniero.me>

This new tests covers the parser errors we support.

Signed-off-by: Carlos Maniero <carlos@maniero.me>
---
 tests/integration/tests/0002_fn_without_fn_keyword.ol     | 8 ++++++++
 tests/integration/tests/0003_fn_without_type.ol           | 8 ++++++++
 tests/integration/tests/0004_fn_without_type_colon.ol     | 8 ++++++++
 .../tests/0005_fn_without_open_curly_brackets.ol          | 8 ++++++++
 .../tests/0006_fn_without_close_curly_brackets.ol         | 7 +++++++
 tests/integration/tests/0007_fn_without_return.ol         | 8 ++++++++
 6 files changed, 47 insertions(+)
 create mode 100644 tests/integration/tests/0002_fn_without_fn_keyword.ol
 create mode 100644 tests/integration/tests/0003_fn_without_type.ol
 create mode 100644 tests/integration/tests/0004_fn_without_type_colon.ol
 create mode 100644 tests/integration/tests/0005_fn_without_open_curly_brackets.ol
 create mode 100644 tests/integration/tests/0006_fn_without_close_curly_brackets.ol
 create mode 100644 tests/integration/tests/0007_fn_without_return.ol

diff --git a/tests/integration/tests/0002_fn_without_fn_keyword.ol b/tests/integration/tests/0002_fn_without_fn_keyword.ol
new file mode 100644
index 0000000..f1ad57e
--- /dev/null
+++ b/tests/integration/tests/0002_fn_without_fn_keyword.ol
@@ -0,0 +1,8 @@
+# spec: An invalid program with no fn keyword
+main(): u32 {
+  return 0
+}
+# compiler_exit: 1
+# compiler_output: ./tests/0002_fn_without_fn_keyword.ol:2:1: error: got 'main' token but expect <fn>
+# compiler_output: main(): u32 {
+# compiler_output: ^
diff --git a/tests/integration/tests/0003_fn_without_type.ol b/tests/integration/tests/0003_fn_without_type.ol
new file mode 100644
index 0000000..32716e1
--- /dev/null
+++ b/tests/integration/tests/0003_fn_without_type.ol
@@ -0,0 +1,8 @@
+# spec: An invalid program with no type
+fn main(): {
+  return 0
+}
+# compiler_exit: 1
+# compiler_output: ./tests/0003_fn_without_type.ol:2:12: error: got '{' token but expect <identifier>
+# compiler_output: fn main(): {
+# compiler_output:            ^
diff --git a/tests/integration/tests/0004_fn_without_type_colon.ol b/tests/integration/tests/0004_fn_without_type_colon.ol
new file mode 100644
index 0000000..bd04c37
--- /dev/null
+++ b/tests/integration/tests/0004_fn_without_type_colon.ol
@@ -0,0 +1,8 @@
+# spec: An invalid program with no type colon
+fn main() u32 {
+  return 0
+}
+# compiler_exit: 1
+# compiler_output: ./tests/0004_fn_without_type_colon.ol:2:11: error: got 'u32' token but expect <:>
+# compiler_output: fn main() u32 {
+# compiler_output:           ^
diff --git a/tests/integration/tests/0005_fn_without_open_curly_brackets.ol b/tests/integration/tests/0005_fn_without_open_curly_brackets.ol
new file mode 100644
index 0000000..8e13946
--- /dev/null
+++ b/tests/integration/tests/0005_fn_without_open_curly_brackets.ol
@@ -0,0 +1,8 @@
+# spec: An invalid program with no open curly brackets
+fn main(): u32
+  return 0
+}
+# compiler_exit: 1
+# compiler_output: ./tests/0005_fn_without_open_curly_brackets.ol:3:3: error: got 'return' token but expect <{>
+# compiler_output:   return 0
+# compiler_output:   ^
diff --git a/tests/integration/tests/0006_fn_without_close_curly_brackets.ol b/tests/integration/tests/0006_fn_without_close_curly_brackets.ol
new file mode 100644
index 0000000..d43c9f9
--- /dev/null
+++ b/tests/integration/tests/0006_fn_without_close_curly_brackets.ol
@@ -0,0 +1,7 @@
+# spec: An invalid program with no close curly brackets
+fn main(): u32 {
+  return 0
+# compiler_exit: 1
+# compiler_output: ./tests/0006_fn_without_close_curly_brackets.ol:8:1: error: got '' token but expect <}>
+# compiler_output: 
+# compiler_output: ^
diff --git a/tests/integration/tests/0007_fn_without_return.ol b/tests/integration/tests/0007_fn_without_return.ol
new file mode 100644
index 0000000..fe33d69
--- /dev/null
+++ b/tests/integration/tests/0007_fn_without_return.ol
@@ -0,0 +1,8 @@
+# spec: An invalid program without return statment
+# TODO: Improve the compiler error message
+fn main(): u32 {
+}
+# compiler_exit: 1
+# compiler_output: ./tests/0007_fn_without_return.ol:4:1: error: got '}' token but expect <return>
+# compiler_output: }
+# compiler_output: ^
-- 
2.34.1


  parent reply	other threads:[~2024-05-12 14:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-12 14:30 [PATCH olang 0/4] comment based integration tests Carlos Maniero
2024-05-12 14:30 ` [PATCH olang 1/4] tests: add comment based integration tests mechanism Carlos Maniero
2024-05-12 14:30 ` [PATCH olang 2/4] tests: remove previous integration tests structure Carlos Maniero
2024-05-12 14:30 ` Carlos Maniero [this message]
2024-05-12 14:30 ` [PATCH olang 4/4] tests: print integration tests TODOs Carlos Maniero
2024-05-12 14:31   ` [olang/patches/.build.yml] build success builds.sr.ht
2024-08-09 19:42 ` [PATCH olang 0/4] comment based integration tests Johnny Richard
2024-08-21 15:58 ` Johnny Richard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240512143033.229961-4-carlos@maniero.me \
    --to=carlos@maniero.me \
    --cc=~johnnyrichard/olang-devel@lists.sr.ht \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.johnnyrichard.com/olang.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox