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:
2026-01-25 03:58:39 +00:00
parent 74ef5cbc11
commit 46fc2e2470
139 changed files with 5078 additions and 73 deletions
+19
View File
@@ -0,0 +1,19 @@
// retoor <retoor@molodetz.nl>
import "tempfile" for TempFile
import "io" for Directory, File
import "pathlib" for Path
var baseDir = TempFile.mkdtemp()
var path = TempFile.mkstemp("", "tmp", baseDir)
System.print(path.startsWith(baseDir)) // expect: true
System.print(Path.new(path).exists()) // expect: true
File.delete(path)
var dir = TempFile.mkdtemp("", "tmp", baseDir)
System.print(dir.startsWith(baseDir)) // expect: true
System.print(Path.new(dir).isDir()) // expect: true
Directory.delete(dir)
Directory.delete(baseDir)
+16
View File
@@ -0,0 +1,16 @@
// retoor <retoor@molodetz.nl>
import "tempfile" for TempFile
var dir = TempFile.gettempdir()
System.print(dir is String) // expect: true
System.print(dir.count > 0) // expect: true
System.print(TempFile.gettempprefix()) // expect: tmp
System.print(TempFile.tempdir == null) // expect: true
TempFile.tempdir = "/custom/path"
System.print(TempFile.gettempdir()) // expect: /custom/path
TempFile.tempdir = null
+18
View File
@@ -0,0 +1,18 @@
// retoor <retoor@molodetz.nl>
import "tempfile" for TempFile
import "io" for Directory
import "pathlib" for Path
var dir = TempFile.mkdtemp()
System.print(dir is String) // expect: true
System.print(Path.new(dir).exists()) // expect: true
System.print(Path.new(dir).isDir()) // expect: true
Directory.delete(dir)
System.print(Path.new(dir).exists()) // expect: false
var dir2 = TempFile.mkdtemp("_end", "mydir_")
System.print(dir2.contains("mydir_")) // expect: true
System.print(dir2.endsWith("_end")) // expect: true
Directory.delete(dir2)
+21
View File
@@ -0,0 +1,21 @@
// retoor <retoor@molodetz.nl>
import "tempfile" for TempFile
import "io" for File
import "pathlib" for Path
var path = TempFile.mkstemp()
System.print(path is String) // expect: true
System.print(Path.new(path).exists()) // expect: true
File.delete(path)
System.print(Path.new(path).exists()) // expect: false
var path2 = TempFile.mkstemp(".txt")
System.print(path2.endsWith(".txt")) // expect: true
File.delete(path2)
var path3 = TempFile.mkstemp(".dat", "test_")
System.print(path3.contains("test_")) // expect: true
System.print(path3.endsWith(".dat")) // expect: true
File.delete(path3)
+13
View File
@@ -0,0 +1,13 @@
// retoor <retoor@molodetz.nl>
import "tempfile" for TempFile
import "pathlib" for Path
var name = TempFile.mktemp()
System.print(name is String) // expect: true
System.print(name.count > 0) // expect: true
System.print(Path.new(name).exists()) // expect: false
var name2 = TempFile.mktemp(".log", "app_")
System.print(name2.contains("app_")) // expect: true
System.print(name2.endsWith(".log")) // expect: true
+18
View File
@@ -0,0 +1,18 @@
// retoor <retoor@molodetz.nl>
import "tempfile" for NamedTemporaryFile
import "pathlib" for Path
var tmp = NamedTemporaryFile.new()
System.print(tmp.name is String) // expect: true
System.print(Path.new(tmp.name).exists()) // expect: true
System.print(tmp.closed) // expect: false
System.print(tmp.delete) // expect: true
tmp.write("hello tempfile")
var content = tmp.read()
System.print(content) // expect: hello tempfile
tmp.close()
System.print(tmp.closed) // expect: true
System.print(Path.new(tmp.name).exists()) // expect: false
+18
View File
@@ -0,0 +1,18 @@
// retoor <retoor@molodetz.nl>
import "tempfile" for NamedTemporaryFile
import "io" for File
import "pathlib" for Path
var tmp = NamedTemporaryFile.new("", "tmp", null, false)
System.print(tmp.delete) // expect: false
tmp.write("persistent")
tmp.close()
System.print(tmp.closed) // expect: true
System.print(Path.new(tmp.name).exists()) // expect: true
var content = File.read(tmp.name)
System.print(content) // expect: persistent
File.delete(tmp.name)
+15
View File
@@ -0,0 +1,15 @@
// retoor <retoor@molodetz.nl>
import "tempfile" for NamedTemporaryFile
import "pathlib" for Path
var savedName = null
NamedTemporaryFile.new().use {|tmp|
tmp.write("inside use block")
var content = tmp.read()
System.print(content) // expect: inside use block
savedName = tmp.name
}
System.print(Path.new(savedName).exists()) // expect: false
+15
View File
@@ -0,0 +1,15 @@
// retoor <retoor@molodetz.nl>
import "tempfile" for TemporaryDirectory
import "pathlib" for Path
var tmp = TemporaryDirectory.new()
System.print(tmp.name is String) // expect: true
System.print(Path.new(tmp.name).exists()) // expect: true
System.print(Path.new(tmp.name).isDir()) // expect: true
System.print(tmp.closed) // expect: false
System.print(tmp.delete) // expect: true
tmp.cleanup()
System.print(tmp.closed) // expect: true
System.print(Path.new(tmp.name).exists()) // expect: false
+20
View File
@@ -0,0 +1,20 @@
// retoor <retoor@molodetz.nl>
import "tempfile" for TemporaryDirectory
import "io" for File, FileFlags
import "pathlib" for Path
var savedName = null
TemporaryDirectory.new().use {|tmp|
savedName = tmp.name
System.print(Path.new(savedName).isDir()) // expect: true
var filePath = savedName + "/test.txt"
File.create(filePath) {|f|
f.writeBytes("hello", 0)
}
System.print(Path.new(filePath).exists()) // expect: true
}
System.print(Path.new(savedName).exists()) // expect: false