feat: add async/await keywords, Num/String extensions, and Jinja markdown example
Add `async` and `await` token support to the Wren compiler with scheduler resolution logic, extend `Num` with `e` constant, hyperbolic trig, base conversion, and new methods (`isZero`, `gcd`, `lcm`, `digits`, etc.), extend `String` with `lower`, `upper`, `capitalize`, `title`, and regenerate `wren_core.wren.inc`. Include `Makefile` for multi-platform builds, rewrite `README.md` with updated build instructions, and add `example/await_demo.wren` and `example/jinja_markdown.wren` demonstrating new features.
This commit is contained in:
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
System.print("Hello World".lower) // expect: hello world
|
||||
System.print("HELLO".lower) // expect: hello
|
||||
System.print("hello".lower) // expect: hello
|
||||
System.print("".lower) // expect:
|
||||
System.print("123!@#".lower) // expect: 123!@#
|
||||
|
||||
System.print("Hello World".upper) // expect: HELLO WORLD
|
||||
System.print("hello".upper) // expect: HELLO
|
||||
System.print("HELLO".upper) // expect: HELLO
|
||||
System.print("".upper) // expect:
|
||||
System.print("123!@#".upper) // expect: 123!@#
|
||||
|
||||
System.print("hello world".capitalize) // expect: Hello world
|
||||
System.print("HELLO".capitalize) // expect: Hello
|
||||
System.print("h".capitalize) // expect: H
|
||||
System.print("".capitalize) // expect:
|
||||
System.print("already Capitalized".capitalize) // expect: Already capitalized
|
||||
|
||||
System.print("hello world".title) // expect: Hello World
|
||||
System.print("HELLO WORLD".title) // expect: Hello World
|
||||
System.print("hello".title) // expect: Hello
|
||||
System.print("".title) // expect:
|
||||
System.print("multi\tword\ntest".title) // expect: Multi Word
|
||||
// expect: Test
|
||||
|
||||
System.print("Hello World".swapCase) // expect: hELLO wORLD
|
||||
System.print("hello".swapCase) // expect: HELLO
|
||||
System.print("HELLO".swapCase) // expect: hello
|
||||
System.print("".swapCase) // expect:
|
||||
System.print("123".swapCase) // expect: 123
|
||||
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
System.print("hello".isLower) // expect: true
|
||||
System.print("Hello".isLower) // expect: false
|
||||
System.print("HELLO".isLower) // expect: false
|
||||
System.print("123".isLower) // expect: false
|
||||
System.print("".isLower) // expect: false
|
||||
|
||||
System.print("HELLO".isUpper) // expect: true
|
||||
System.print("Hello".isUpper) // expect: false
|
||||
System.print("hello".isUpper) // expect: false
|
||||
System.print("123".isUpper) // expect: false
|
||||
System.print("".isUpper) // expect: false
|
||||
|
||||
System.print("12345".isDigit) // expect: true
|
||||
System.print("123a5".isDigit) // expect: false
|
||||
System.print("".isDigit) // expect: false
|
||||
System.print("0".isDigit) // expect: true
|
||||
|
||||
System.print("hello".isAlpha) // expect: true
|
||||
System.print("Hello".isAlpha) // expect: true
|
||||
System.print("hello1".isAlpha) // expect: false
|
||||
System.print("".isAlpha) // expect: false
|
||||
|
||||
System.print("hello123".isAlphaNumeric) // expect: true
|
||||
System.print("Hello".isAlphaNumeric) // expect: true
|
||||
System.print("12345".isAlphaNumeric) // expect: true
|
||||
System.print("hello!".isAlphaNumeric) // expect: false
|
||||
System.print("".isAlphaNumeric) // expect: false
|
||||
|
||||
System.print(" ".isSpace) // expect: true
|
||||
System.print(" \t\n".isSpace) // expect: true
|
||||
System.print("hello".isSpace) // expect: false
|
||||
System.print("".isSpace) // expect: false
|
||||
|
||||
System.print("hello".isAscii) // expect: true
|
||||
System.print("123!@#".isAscii) // expect: true
|
||||
System.print("".isAscii) // expect: true
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
System.print("42".toNum) // expect: 42
|
||||
System.print("3.14".toNum) // expect: 3.14
|
||||
System.print("-7".toNum) // expect: -7
|
||||
System.print("abc".toNum) // expect: null
|
||||
System.print("".toNum) // expect: null
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
System.print("hello world hello".lastIndexOf("hello")) // expect: 12
|
||||
System.print("hello".lastIndexOf("hello")) // expect: 0
|
||||
System.print("hello".lastIndexOf("x")) // expect: -1
|
||||
System.print("aaaa".lastIndexOf("aa")) // expect: 2
|
||||
System.print("".lastIndexOf("x")) // expect: -1
|
||||
|
||||
System.print("hello world hello".lastIndexOf("hello", 11)) // expect: 0
|
||||
System.print("hello world hello".lastIndexOf("hello", 12)) // expect: 12
|
||||
System.print("hello world hello".lastIndexOf("hello", 100)) // expect: 12
|
||||
System.print("hello".lastIndexOf("x", 3)) // expect: -1
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
var lines = "line1\nline2\nline3".splitLines
|
||||
System.print(lines.count) // expect: 3
|
||||
System.print(lines[0]) // expect: line1
|
||||
System.print(lines[1]) // expect: line2
|
||||
System.print(lines[2]) // expect: line3
|
||||
|
||||
var crlfLines = "a\r\nb\r\nc".splitLines
|
||||
System.print(crlfLines.count) // expect: 3
|
||||
System.print(crlfLines[0]) // expect: a
|
||||
System.print(crlfLines[1]) // expect: b
|
||||
System.print(crlfLines[2]) // expect: c
|
||||
|
||||
var chars = "abc".chars
|
||||
System.print(chars.count) // expect: 3
|
||||
System.print(chars[0]) // expect: a
|
||||
System.print(chars[1]) // expect: b
|
||||
System.print(chars[2]) // expect: c
|
||||
|
||||
System.print("".chars.count) // expect: 0
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
System.print("hello".reverse) // expect: olleh
|
||||
System.print("".reverse) // expect:
|
||||
System.print("a".reverse) // expect: a
|
||||
System.print("abcde".reverse) // expect: edcba
|
||||
|
||||
System.print("[%("hi".center(10))]") // expect: [ hi ]
|
||||
System.print("hi".center(10, "-")) // expect: ----hi----
|
||||
System.print("hello".center(3)) // expect: hello
|
||||
System.print("x".center(5, ".")) // expect: ..x..
|
||||
|
||||
System.print("42".lpad(5, "0")) // expect: 00042
|
||||
System.print("hello".lpad(3, "x")) // expect: hello
|
||||
System.print("a".lpad(5, "-")) // expect: ----a
|
||||
|
||||
System.print("hi".rpad(5, ".")) // expect: hi...
|
||||
System.print("hello".rpad(3, "x")) // expect: hello
|
||||
System.print("a".rpad(5, "-")) // expect: a----
|
||||
|
||||
System.print("42".zfill(5)) // expect: 00042
|
||||
System.print("-42".zfill(6)) // expect: -00042
|
||||
System.print("+42".zfill(6)) // expect: +00042
|
||||
System.print("12345".zfill(3)) // expect: 12345
|
||||
|
||||
System.print("HelloWorld".removePrefix("Hello")) // expect: World
|
||||
System.print("HelloWorld".removePrefix("World")) // expect: HelloWorld
|
||||
System.print("".removePrefix("x")) // expect:
|
||||
|
||||
System.print("HelloWorld".removeSuffix("World")) // expect: Hello
|
||||
System.print("HelloWorld".removeSuffix("Hello")) // expect: HelloWorld
|
||||
System.print("".removeSuffix("x")) // expect:
|
||||
Reference in New Issue
Block a user