Implement Process.version (#42)
* Implement `Process.version` * Update`os` test suite
This commit is contained in:
parent
1ab88ed201
commit
e4a0fa485e
@ -25,6 +25,7 @@ extern void fileWriteBytes(WrenVM* vm);
|
||||
extern void platformIsPosix(WrenVM* vm);
|
||||
extern void platformName(WrenVM* vm);
|
||||
extern void processAllArguments(WrenVM* vm);
|
||||
extern void processVersion(WrenVM* vm);
|
||||
extern void processCwd(WrenVM* vm);
|
||||
extern void statPath(WrenVM* vm);
|
||||
extern void statBlockCount(WrenVM* vm);
|
||||
@ -166,6 +167,7 @@ static ModuleRegistry modules[] =
|
||||
END_CLASS
|
||||
CLASS(Process)
|
||||
STATIC_METHOD("allArguments", processAllArguments)
|
||||
STATIC_METHOD("version", processVersion)
|
||||
STATIC_METHOD("cwd", processCwd)
|
||||
END_CLASS
|
||||
END_MODULE
|
||||
|
||||
@ -71,6 +71,12 @@ void processAllArguments(WrenVM* vm)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void processVersion(WrenVM* vm) {
|
||||
wrenEnsureSlots(vm, 1);
|
||||
wrenSetSlotString(vm, 0, WREN_VERSION_STRING);
|
||||
}
|
||||
|
||||
void processCwd(WrenVM* vm)
|
||||
{
|
||||
wrenEnsureSlots(vm, 1);
|
||||
|
||||
@ -10,5 +10,6 @@ class Process {
|
||||
static arguments { allArguments[2..-1] }
|
||||
|
||||
foreign static allArguments
|
||||
foreign static version
|
||||
foreign static cwd
|
||||
}
|
||||
|
||||
@ -12,5 +12,6 @@ static const char* osModuleSource =
|
||||
" static arguments { allArguments[2..-1] }\n"
|
||||
"\n"
|
||||
" foreign static allArguments\n"
|
||||
" foreign static version\n"
|
||||
" foreign static cwd\n"
|
||||
"}\n";
|
||||
|
||||
7
test/os/process/version.wren
Normal file
7
test/os/process/version.wren
Normal file
@ -0,0 +1,7 @@
|
||||
import "os" for Process
|
||||
|
||||
System.print(Process.version is String) // expect: true
|
||||
System.print(Process.version.isEmpty) // expect: false
|
||||
|
||||
var isNumber = Fn.new {|str| Num.fromString(str) != null }
|
||||
System.print(Process.version.split(".").all(isNumber)) // expect: true
|
||||
Loading…
Reference in New Issue
Block a user