Skip to content

Commit 5ab02ee

Browse files
authored
Merge pull request #237 from roc-lang/all_syntax_file
all syntax demo
2 parents 7c85e84 + 6805f16 commit 5ab02ee

File tree

7 files changed

+479
-6
lines changed

7 files changed

+479
-6
lines changed

ci_scripts/all_tests.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ expect ci_scripts/expect_scripts/Parser.exp
3939

4040
$ROC test ./examples/PatternMatching/PatternMatching.roc
4141

42+
$ROC build ./examples/AllSyntax/main.roc
43+
expect ci_scripts/expect_scripts/AllSyntax.exp
44+
4245
$ROC build ./examples/RandomNumbers/main.roc
4346
expect ci_scripts/expect_scripts/RandomNumbers.exp
4447

ci_scripts/check_format.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ if [ -z "${ROC}" ]; then
1717
fi
1818

1919
# array of paths to exclude from format check
20-
# TODO: remove the exclusion of examples/Tasks/main.roc when
21-
# https://github.com/roc-lang/roc/issues/6074 is done
22-
excludes=( './examples/Tasks/main.roc' './roc_nightly/' )
20+
# AllSyntax: The formatter changes `||`` into `or`, and we want to demonstrate both in the example
21+
excludes=( './examples/AllSyntax/main.roc' './roc_nightly/' )
2322

2423
# Start the find command and loop through excludes to add them
2524
find_command="find . -name '*.roc'"
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/expect
2+
3+
# uncomment line below for debugging
4+
# exp_internal 1
5+
6+
set timeout 7
7+
8+
source ./ci_scripts/expect_scripts/shared-code.exp
9+
10+
spawn ./examples/AllSyntax/main
11+
12+
set expected_output [normalize_output {
13+
\{diff: 5, div: 2, div_trunc: 2, eq: Bool.false, gt: Bool.true, gteq: Bool.true, lt: Bool.false, lteq: Bool.false, neg: -10, neq: Bool.true, prod: 50, rem: 0, sum: 15\}
14+
\{bool_and: Bool.false, bool_and_keyword: Bool.false, bool_or: Bool.true, bool_or_keyword: Bool.true, not_a: Bool.false\}
15+
"Pizza Roc"
16+
42
17+
Hello, Venus!This is a multiline string.
18+
You can call functions inside $... too: 2
19+
Unicode escape sequence:  
20+
"Success"
21+
Hello, world!
22+
Hello, world!
23+
Hello, world!
24+
Hello, world!
25+
Hello, world!
26+
(Ok \{\})
27+
"False"
28+
("Roc", 1)
29+
Red
30+
\[1, 2\]
31+
(TagFour 42)
32+
default
33+
("Roc", 1, 1, 1)
34+
\{x: 1, y: 3\}
35+
44
36+
\[./examples/AllSyntax/main.roc:121\] a = 42
37+
\[./examples/AllSyntax/main.roc:124\] 43 = 43
38+
\{\}
39+
4
40+
(5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5.0, 5, 5, 5)
41+
Rocco
42+
42
43+
99
44+
(Ok \{age: 25, city: "NYC", name: "Alice"\})
45+
Bool.true
46+
}]
47+
48+
expect $expected_output {
49+
expect eof {
50+
check_exit_and_segfault
51+
}
52+
}
53+
puts stderr "\nError: output was different from expected value."
54+
exit 1

examples/AllSyntax/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# All Syntax File
2+
3+
Demonstrates all Roc syntax in a single app file. See [all module types](https://roc-lang.org/tutorial#modules) to view syntax examples for the non-app headers.
4+
5+
## Code
6+
```roc
7+
file:main.roc
8+
```
9+
10+
## Output
11+
12+
Run this from the directory that has `main.roc` in it:
13+
14+
```
15+
$ roc main.roc
16+
{diff: 5, div: 2, div_trunc: 2, eq: Bool.false, gt: Bool.true, gteq: Bool.true, lt: Bool.false, lteq: Bool.false, neg: -10, neq: Bool.true, prod: 50, rem: 0, sum: 15}
17+
{bool_and: Bool.false, bool_and_keyword: Bool.false, bool_or: Bool.true, bool_or_keyword: Bool.true, not_a: Bool.false}
18+
"Pizza Roc"
19+
42
20+
Hello, Venus!This is a multiline string.
21+
You can call functions inside $... too: 2
22+
Unicode escape sequence:  
23+
"Success"
24+
Hello, world!
25+
Hello, world!
26+
Hello, world!
27+
Hello, world!
28+
Hello, world!
29+
(Ok {})
30+
"False"
31+
("Roc", 1)
32+
Red
33+
[1, 2]
34+
(TagFour 42)
35+
default
36+
("Roc", 1, 1, 1)
37+
{x: 1, y: 3}
38+
44
39+
[./examples/AllSyntax/main.roc:119] a = 42
40+
[./examples/AllSyntax/main.roc:122] 43 = 43
41+
{}
42+
4
43+
(5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5.0, 5, 5, 5)
44+
Rocco
45+
42
46+
99
47+
(Ok {age: 25, city: "NYC", name: "Alice"})
48+
Bool.true
49+
```
50+

0 commit comments

Comments
 (0)