Skip to content

Commit

Permalink
tests: add tests for comptime
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Aug 7, 2024
1 parent 6edb3ed commit dfce200
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 7 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/test_gcc_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ jobs:
- name: Test - Basic Calculator
run: |
.\bin\julec --compiler gcc -o test tests/basic_calculator
- name: Test - Comptime
run: |
.\bin\julec --compiler gcc -o test tests/comptime
./test
- name: Test - Concurrency
run: |
.\bin\julec --compiler gcc -o test tests/concurrency
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/tests_clang_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ jobs:
- name: Test - Basic Calculator
run: |
julec --compiler clang -o test tests/basic_calculator
- name: Test - Comptime
run: |
julec --compiler clang -o test tests/comptime
./test
- name: Test - Concurrency
run: |
julec --compiler clang -o test tests/concurrency
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/tests_clang_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ jobs:
- name: Test - Basic Calculator
run: |
julec --compiler clang -o test tests/basic_calculator
- name: Test - Comptime
run: |
julec --compiler clang -o test tests/comptime
./test
- name: Test - Concurrency
run: |
julec --compiler clang -o test tests/concurrency
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/tests_clang_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ jobs:
- name: Test - Basic Calculator
run: |
.\bin\julec --compiler clang -o test tests/basic_calculator
- name: Test - Comptime
run: |
.\bin\julec --compiler clang -o test tests/comptime
./test
- name: Test - Concurrency
run: |
.\bin\julec --compiler clang -o test tests/concurrency
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/tests_gcc_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ jobs:
run: |
julec --compiler gcc --compiler-path g++-13 -o test -t tests/basic_calculator
g++-13 -w --std=c++17 -O0 -Wl,-ld_classic -o test dist/ir.cpp
- name: Test - Comptime
run: |
julec --compiler gcc --compiler-path g++-13 -o test -t tests/comptime
g++-13 -w --std=c++17 -O0 -Wl,-ld_classic -o test dist/ir.cpp
./test
- name: Test - Concurrency
run: |
julec --compiler gcc --compiler-path g++-13 -o test -t tests/concurrency
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/tests_gcc_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ jobs:
- name: Test - Basic Calculator
run: |
julec --compiler gcc -o test tests/basic_calculator
julec --compiler gcc -o test tests/comptime
- name: Test - Comptime
run: |
julec --compiler gcc -o test tests/comptime
./test
- name: Test - Concurrency
run: |
julec --compiler gcc -o test tests/concurrency
Expand Down
51 changes: 51 additions & 0 deletions tests/comptime/match.jule
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2024 The Jule Programming Language.
// Use of this source code is governed by a BSD 3-Clause
// license that can be found in the LICENSE file.

use comptime for std::comptime

fn match1() {
match comptime::Match(comptime::TypeOf(int)) {
| comptime::TypeOf(&int):
outln("foo")
| comptime::TypeOf(bool):
outln("bar")
|:
outln("baz")
}
}

fn match2() {
match comptime::Match(20) {
| 20:
outln("foo")
| 40:
outln("bar")
|:
outln("baz")
}
}

fn typeMatch1() {
match type comptime::Match(20) {
| int:
outln("foo")
| bool:
outln("bar")
|:
outln("baz")
}
}

fn typeMatch2() {
match type comptime::Match(comptime::TypeOf(int)) {
| *int:
outln("foo")
| bool:
outln("bar")
|:
outln("baz")
}
}

fn main() {}

0 comments on commit dfce200

Please sign in to comment.