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
+6
@@ -0,0 +1,6 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
System.print(Num.pi.toDegrees) // expect: 180
|
||||
System.print(180.toRadians == Num.pi) // expect: true
|
||||
System.print(0.toDegrees) // expect: 0
|
||||
System.print(0.toRadians) // expect: 0
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
System.print(Num.e > 2.718) // expect: true
|
||||
System.print(Num.e < 2.719) // expect: true
|
||||
System.print(1.log == 0) // expect: true
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
System.print(65.toChar) // expect: A
|
||||
System.print(97.toChar) // expect: a
|
||||
System.print(48.toChar) // expect: 0
|
||||
|
||||
System.print(255.toBase(16)) // expect: ff
|
||||
System.print(255.toBase(2)) // expect: 11111111
|
||||
System.print(255.toBase(8)) // expect: 377
|
||||
System.print(0.toBase(16)) // expect: 0
|
||||
System.print((-42).toBase(10)) // expect: -42
|
||||
System.print(35.toBase(36)) // expect: z
|
||||
|
||||
System.print(255.toHex) // expect: ff
|
||||
System.print(10.toBinary) // expect: 1010
|
||||
System.print(8.toOctal) // expect: 10
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
System.print(3.14159.format(2)) // expect: 3.14
|
||||
System.print(3.14159.format(0)) // expect: 3
|
||||
System.print(42.format(3)) // expect: 42.000
|
||||
System.print((-1.5).format(1)) // expect: -1.5
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
System.print(12.gcd(8)) // expect: 4
|
||||
System.print(54.gcd(24)) // expect: 6
|
||||
System.print(7.gcd(13)) // expect: 1
|
||||
System.print(0.gcd(5)) // expect: 5
|
||||
System.print((-12).gcd(8)) // expect: 4
|
||||
|
||||
System.print(4.lcm(6)) // expect: 12
|
||||
System.print(3.lcm(5)) // expect: 15
|
||||
System.print(0.lcm(5)) // expect: 0
|
||||
System.print(0.lcm(0)) // expect: 0
|
||||
|
||||
System.print(123.digits) // expect: [1, 2, 3]
|
||||
System.print(0.digits) // expect: [0]
|
||||
System.print((-456).digits) // expect: [4, 5, 6]
|
||||
System.print(9.digits) // expect: [9]
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
System.print(100.log10) // expect: 2
|
||||
System.print(1000.log10) // expect: 3
|
||||
System.print(1.log10) // expect: 0
|
||||
|
||||
System.print(0.sinh) // expect: 0
|
||||
System.print(0.cosh) // expect: 1
|
||||
System.print(0.tanh) // expect: 0
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
System.print(0.isZero) // expect: true
|
||||
System.print(1.isZero) // expect: false
|
||||
System.print((-1).isZero) // expect: false
|
||||
|
||||
System.print(5.isPositive) // expect: true
|
||||
System.print(0.isPositive) // expect: false
|
||||
System.print((-3).isPositive) // expect: false
|
||||
|
||||
System.print((-7).isNegative) // expect: true
|
||||
System.print(0.isNegative) // expect: false
|
||||
System.print(3.isNegative) // expect: false
|
||||
|
||||
System.print(42.isFinite) // expect: true
|
||||
System.print(0.isFinite) // expect: true
|
||||
System.print((1/0).isFinite) // expect: false
|
||||
System.print((0/0).isFinite) // expect: false
|
||||
|
||||
System.print(4.isEven) // expect: true
|
||||
System.print(3.isEven) // expect: false
|
||||
System.print(0.isEven) // expect: true
|
||||
System.print(1.5.isEven) // expect: false
|
||||
|
||||
System.print(3.isOdd) // expect: true
|
||||
System.print(4.isOdd) // expect: false
|
||||
System.print(0.isOdd) // expect: false
|
||||
System.print(1.5.isOdd) // expect: false
|
||||
|
||||
System.print(5.isBetween(1, 10)) // expect: true
|
||||
System.print(1.isBetween(1, 10)) // expect: true
|
||||
System.print(10.isBetween(1, 10)) // expect: true
|
||||
System.print(0.isBetween(1, 10)) // expect: false
|
||||
System.print(11.isBetween(1, 10)) // expect: false
|
||||
Reference in New Issue
Block a user