Skip to content

Commit

Permalink
Merge pull request #10 from DilsonHiga/main
Browse files Browse the repository at this point in the history
Adds an example and avoid a bug on the compiler
  • Loading branch information
lukewilliamboswell authored Jul 1, 2024
2 parents e8b1f01 + 8ff65ea commit 364b7a6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Ignore the example binaries
examples/simple
examples/visualWidth
example/splitGraphemes

# Ignore the generated files
generated-docs
Expand Down
20 changes: 20 additions & 0 deletions examples/splitGraphemes.roc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
app [main] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.11.0/SY4WWMhWQ9NvQgvIthcv15AUeA7rAIJHAHgiaSHGhdY.tar.br",
unicode: "../package/main.roc", # use release URL (ends in tar.br) for local example, see github.com/roc/unicode/releases
}

import pf.Stdout
import pf.Task
import unicode.Grapheme

string = "🇦🇺🦘🪃"

expect Grapheme.split string == Ok ["🇦🇺", "🦘", "🪃"]

main =
string
|> Grapheme.split
|> Inspect.toStr
|> \splitted ->
Stdout.line! "\n\nThe string \"$(string)\" has following graphemes:"
Stdout.line! splitted
7 changes: 2 additions & 5 deletions package/CodePoint.roc
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ appendUtf8 = \bytes, codePoint ->
else
## This was an invalid Unicode scalar value, even though it had the Roc type Scalar.
## This should never happen!
expect
u32 < 0x110000
# expect u32 < 0x110000

byte1 =
u32
Expand Down Expand Up @@ -179,9 +178,7 @@ countUtf8Bytes = \codePoint ->
3
else
# If this expectation fails, it was an invalid Scalar and shouldn't have been allowed!
expect
u32 < 0x110000

# expect u32 < 0x110000
4

## parse a 2-byte code point
Expand Down
2 changes: 1 addition & 1 deletion package/GraphemeTestGen.roc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## parse it and then generate the individual tests.
app [main] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.11.0/SY4WWMhWQ9NvQgvIthcv15AUeA7rAIJHAHgiaSHGhdY.tar.br",
parser: "https://github.com/lukewilliamboswell/roc-parser/releases/download/0.5.2/9VrPjwfQQ1QeSL3CfmWr2Pr9DESdDIXy97pwpuq84Ck.tar.br",
parser: "https://github.com/lukewilliamboswell/roc-parser/releases/download/0.7.1/MvLlME9RxOBjl0QCxyn3LIaoG9pSlaNxCa-t3BfbPNc.tar.br",
}

import pf.Task exposing [Task]
Expand Down

0 comments on commit 364b7a6

Please sign in to comment.