mirror of https://github.com/svaarala/duktape.git
Sami Vaarala
11 years ago
3 changed files with 75 additions and 3 deletions
@ -0,0 +1,22 @@ |
|||
/* |
|||
* Yielding from eval code is currently not allowed and should |
|||
* cause a clean TypeError. |
|||
*/ |
|||
|
|||
/*=== |
|||
TypeError |
|||
===*/ |
|||
|
|||
function test_eval() { |
|||
var t = new __duk__.Thread(function() { |
|||
eval('__duk__.Thread.yield(1234)'); |
|||
}); |
|||
__duk__.Thread.resume(t) |
|||
} |
|||
|
|||
try { |
|||
test_eval(); |
|||
} catch (e) { |
|||
print(e.name); |
|||
} |
|||
|
@ -0,0 +1,50 @@ |
|||
/* |
|||
* Yielding from a getter/setter is currently not allowed and should |
|||
* cause a clean TypeError. |
|||
*/ |
|||
|
|||
/*=== |
|||
TypeError |
|||
TypeError |
|||
===*/ |
|||
|
|||
function getter() { |
|||
__duk__.Thread.yield('foo') |
|||
} |
|||
|
|||
function setter() { |
|||
__duk__.Thread.yield('bar') |
|||
} |
|||
|
|||
var obj = { |
|||
get a() { getter(); }, |
|||
set a() { setter(); } |
|||
} |
|||
|
|||
function test_get() { |
|||
var t = new __duk__.Thread(function() { |
|||
print(obj.a); |
|||
}); |
|||
__duk__.Thread.resume(t) |
|||
} |
|||
|
|||
function test_set() { |
|||
var t = new __duk__.Thread(function() { |
|||
obj.a = 1; |
|||
print('setter ok'); |
|||
}); |
|||
__duk__.Thread.resume(t) |
|||
} |
|||
|
|||
try { |
|||
test_get(); |
|||
} catch (e) { |
|||
print(e.name); |
|||
} |
|||
|
|||
try { |
|||
test_set(); |
|||
} catch (e) { |
|||
print(e.name); |
|||
} |
|||
|
Loading…
Reference in new issue