Browse Source

Add Proxy test to JSON fastpath testcase

pull/198/merge
Sami Vaarala 9 years ago
parent
commit
3d04b9b17f
  1. 41
      tests/ecmascript/test-bi-json-enc-fastpath.js

41
tests/ecmascript/test-bi-json-enc-fastpath.js

@ -264,3 +264,44 @@ try {
} catch (e) { } catch (e) {
print(e.stack || e); print(e.stack || e);
} }
/*===
proxy test
["begin",{"foo":123},{"foo":345},{"foo":456},{"foo":567},"end"]
===*/
/* A Proxy object causes side effects and should cause abandonment of the
* fast path.
*/
function jsonStringifyFastPathProxyTest() {
var myValue;
var target = { foo: 'bar' };
// side effects chosen so that a restart will generate the same
// result value sequence
var p1 = new Proxy(target, {
get: function() { myValue = 234; return 123; }
});
var p2 = new Proxy(target, {
get: function() { var ret = myValue; myValue = 345; return ret; }
});
var p3 = new Proxy(target, {
get: function() { var ret = myValue; myValue = 456; return ret; }
});
var p4 = new Proxy(target, {
get: function() { var ret = myValue; myValue = 567; return ret; }
});
var obj = [ 'begin', p1, p2, p3, p4, 'end' ];
myValue = 100;
print(JSON.stringify(obj));
}
try {
print('proxy test');
jsonStringifyFastPathProxyTest();
} catch (e) {
print(e.name);
}

Loading…
Cancel
Save