Move the guts of eval-js to its own word, add eval-js-standalone for unit tests
parent
6ecf43b91f
commit
b32782ac9b
|
@ -3,8 +3,8 @@
|
|||
USING: accessors javascriptcore kernel tools.test ;
|
||||
IN: javascriptcore.tests
|
||||
|
||||
[ "2" ] [ "1+1" eval-js ] unit-test
|
||||
[ "2" ] [ "1+1" eval-js-standalone ] unit-test
|
||||
|
||||
[ "1+shoes" eval-js ]
|
||||
[ "1+shoes" eval-js-standalone ]
|
||||
[ error>> "ReferenceError: Can't find variable: shoes" = ] must-fail-with
|
||||
|
||||
|
|
|
@ -35,14 +35,13 @@ SYMBOL: js-context
|
|||
drop f
|
||||
] if* ;
|
||||
|
||||
: eval-js ( string -- result-string )
|
||||
'[
|
||||
[
|
||||
dup _ JSStringCreateWithUTF8CString f f 0 JSValueRef <c-object>
|
||||
[ JSEvaluateScript ] keep *void*
|
||||
dup [ nip JSValueRef>string javascriptcore-error ] [ drop JSValueRef>string ] if
|
||||
] with-global-context
|
||||
] with-javascriptcore ;
|
||||
: eval-js ( context string -- result-string )
|
||||
dupd JSStringCreateWithUTF8CString f f 0 JSValueRef <c-object>
|
||||
[ JSEvaluateScript ] keep *void*
|
||||
dup [ nip JSValueRef>string javascriptcore-error ] [ drop JSValueRef>string ] if ;
|
||||
|
||||
: eval-js-path ( path -- result-string ) utf8 file-contents eval-js ;
|
||||
: eval-js-standalone ( string -- result-string )
|
||||
'[ [ _ eval-js ] with-global-context ] with-javascriptcore ;
|
||||
|
||||
: eval-js-path-standalone ( path -- result-string ) utf8 file-contents eval-js-standalone ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue