Browse Source

yield related test cases

pull/1/head
Sami Vaarala 11 years ago
parent
commit
2d26d7ebf9
  1. 6
      ecmascript-testcases/test-dev-yield-after-callapply.js
  2. 22
      ecmascript-testcases/test-dev-yield-from-eval.js
  3. 50
      ecmascript-testcases/test-dev-yield-from-getset.js

6
ecmascript-testcases/test-dev-bug-yield-after-callapply.js → ecmascript-testcases/test-dev-yield-after-callapply.js

@ -7,8 +7,8 @@ var res;
123
===*/
/* Calling via Function.prototype.call() or Function.prototype.apply() would
* prevent a yield().
/* Calling via Function.prototype.call() or Function.prototype.apply()
* currently prevents a yield.
*/
function innerfunc() {
@ -16,7 +16,7 @@ function innerfunc() {
}
function coroutine1() {
// This is a native call so naive handling would prevent a later yield
// This is a native call so the current (naive) handling prevents a later yield
innerfunc.call();
}

22
ecmascript-testcases/test-dev-yield-from-eval.js

@ -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);
}

50
ecmascript-testcases/test-dev-yield-from-getset.js

@ -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…
Cancel
Save