Browse Source

rename __duk__ to Duktape in testcases

pull/1/head
Sami Vaarala 11 years ago
parent
commit
0e3003179d
  1. 50
      ecmascript-testcases/test-builtin-duk-json-custom.js
  2. 38
      ecmascript-testcases/test-builtin-duk.js
  3. 20
      ecmascript-testcases/test-builtin-json-enc-nonbmp.js
  4. 62
      ecmascript-testcases/test-dev-base64-enc.js
  5. 24
      ecmascript-testcases/test-dev-buffer-pointer-object.js
  6. 2
      ecmascript-testcases/test-dev-bug-finalizer-rescue.js
  7. 6
      ecmascript-testcases/test-dev-bug-stringtable-leak.js
  8. 12
      ecmascript-testcases/test-dev-bug-throw-in-catch.js
  9. 2
      ecmascript-testcases/test-dev-builtin-name-props.js
  10. 12
      ecmascript-testcases/test-dev-coroutine-basic.js
  11. 4
      ecmascript-testcases/test-dev-hex-enc.js
  12. 4
      ecmascript-testcases/test-dev-markandsweep-finalizer-1.js
  13. 18
      ecmascript-testcases/test-dev-markandsweep-finalizer-2.js
  14. 8
      ecmascript-testcases/test-dev-markandsweep-finalizer-3.js
  15. 4
      ecmascript-testcases/test-dev-markandsweep-finalizer-4.js
  16. 4
      ecmascript-testcases/test-dev-refcount-finalizer-1.js
  17. 8
      ecmascript-testcases/test-dev-refcount-finalizer-2.js
  18. 2
      ecmascript-testcases/test-dev-refcount-finalizer-3.js
  19. 10
      ecmascript-testcases/test-dev-yield-after-callapply.js
  20. 8
      ecmascript-testcases/test-dev-yield-from-constructor.js
  21. 6
      ecmascript-testcases/test-dev-yield-from-eval.js
  22. 12
      ecmascript-testcases/test-dev-yield-from-getset.js
  23. 4
      ecmascript-testcases/test-misc-pointer-tostring.js

50
ecmascript-testcases/test-builtin-duk-json-custom.js

@ -10,11 +10,11 @@
---*/ ---*/
function encJsonx(val) { function encJsonx(val) {
return __duk__.jsonxEnc(val); return Duktape.jsonxEnc(val);
} }
function decJsonx(val) { function decJsonx(val) {
return __duk__.jsonxDec(val); return Duktape.jsonxDec(val);
} }
function safedecJsonx(val) { function safedecJsonx(val) {
@ -26,11 +26,11 @@ function safedecJsonx(val) {
} }
function encJsonc(val) { function encJsonc(val) {
return __duk__.jsoncEnc(val); return Duktape.jsoncEnc(val);
} }
function decJsonc(val) { function decJsonc(val) {
return __duk__.jsoncDec(val); return Duktape.jsoncDec(val);
} }
function safedecJsonc(val) { function safedecJsonc(val) {
@ -110,10 +110,10 @@ function typeEncodeTest() {
var values = [ var values = [
undefined, null, true, false, 123.0, 0 / 0, -1 / 0, 1 / 0, undefined, null, true, false, 123.0, 0 / 0, -1 / 0, 1 / 0,
'foo', [1,2,3], { test_key: 123, 'foo bar': 321 }, 'foo', [1,2,3], { test_key: 123, 'foo bar': 321 },
__duk__.dec('hex', 'deadbeef'), // plain buf Duktape.dec('hex', 'deadbeef'), // plain buf
new __duk__.Buffer(__duk__.dec('hex', 'deadbeef')), // object buf new Duktape.Buffer(Duktape.dec('hex', 'deadbeef')), // object buf
__duk__.Pointer(), // plain ptr; null pointer has a deterministic representation Duktape.Pointer(), // plain ptr; null pointer has a deterministic representation
new __duk__.Pointer(), // object ptr new Duktape.Pointer(), // object ptr
function myfunc() {} function myfunc() {}
]; ];
@ -127,14 +127,14 @@ function typeEncodeTest() {
// pointer: match against a pattern since the contents are otherwise // pointer: match against a pattern since the contents are otherwise
// platform dependent // platform dependent
ptr = __duk__.Pointer('dummy'); // non-null plain ptr ptr = Duktape.Pointer('dummy'); // non-null plain ptr
print(typeof ptr); print(typeof ptr);
tmp = encJsonx(ptr); tmp = encJsonx(ptr);
print('jsonx non-null ptr', m_ptr_nonnull_jsonx.test(tmp)); print('jsonx non-null ptr', m_ptr_nonnull_jsonx.test(tmp));
tmp = encJsonc(ptr); tmp = encJsonc(ptr);
print('jsonc non-null ptr', m_ptr_nonnull_jsonc.test(tmp)); print('jsonc non-null ptr', m_ptr_nonnull_jsonc.test(tmp));
ptr = new __duk__.Pointer('dummy'); // non-null object ptr ptr = new Duktape.Pointer('dummy'); // non-null object ptr
print(typeof ptr); print(typeof ptr);
tmp = encJsonx(ptr); tmp = encJsonx(ptr);
print('jsonx non-null ptr', m_ptr_nonnull_jsonx.test(tmp)); print('jsonx non-null ptr', m_ptr_nonnull_jsonx.test(tmp));
@ -145,9 +145,9 @@ function typeEncodeTest() {
function typeDecodeTest(dec) { function typeDecodeTest(dec) {
function dval(t) { function dval(t) {
if (typeof t == 'buffer') { if (typeof t == 'buffer') {
print(typeof t, __duk__.enc('hex', t)); print(typeof t, Duktape.enc('hex', t));
} else if (typeof t == 'pointer') { } else if (typeof t == 'pointer') {
if (t === __duk__.Pointer()) { if (t === Duktape.Pointer()) {
print(typeof t, 'null'); print(typeof t, 'null');
} else { } else {
print(typeof t, 'nonnull'); print(typeof t, 'nonnull');
@ -177,7 +177,7 @@ function typeDecodeTest(dec) {
'[1,2,3]', '[1,2,3]',
'{test_key:"bar","foo bar":"quux"}', '{test_key:"bar","foo bar":"quux"}',
'|deadbeef|', '|deadbeef|',
encJsonx(__duk__.Pointer('dummy')), // pointer format is platform specific so use a pointer generated encJsonx(Duktape.Pointer('dummy')), // pointer format is platform specific so use a pointer generated
// by Duktape; this is obviously not the best idea for testing // by Duktape; this is obviously not the best idea for testing
'(null)', '(null)',
'{_func:true}' '{_func:true}'
@ -260,7 +260,7 @@ SyntaxError
function characterEscapeEncodeTest() { function characterEscapeEncodeTest() {
function mk(hex) { function mk(hex) {
return String(__duk__.dec('hex', hex)); return String(Duktape.dec('hex', hex));
} }
var values = [ var values = [
@ -279,7 +279,7 @@ function characterEscapeEncodeTest() {
function characterEscapeDecodeTest() { function characterEscapeDecodeTest() {
function dump(val) { function dump(val) {
return String(__duk__.enc('hex', val)); return String(Duktape.enc('hex', val));
} }
var values = [ var values = [
@ -590,7 +590,7 @@ non-default encoding options
function nonDefaultEncodingTest() { function nonDefaultEncodingTest() {
var val = { var val = {
foo: 'bar', foo: 'bar',
bar: __duk__.dec('hex', 'deadbeef'), bar: Duktape.dec('hex', 'deadbeef'),
quux: [ quux: [
123, 123,
0 / 0, 0 / 0,
@ -604,11 +604,11 @@ function nonDefaultEncodingTest() {
if (typeof v === 'string') { return v.toUpperCase() } else { return v } if (typeof v === 'string') { return v.toUpperCase() } else { return v }
} }
print(__duk__.jsonxEnc(val, ucStrings /*replacer*/, 4 /*space*/)); print(Duktape.jsonxEnc(val, ucStrings /*replacer*/, 4 /*space*/));
print(__duk__.jsonxEnc(val, [ 'foo', 'bar', 'quux' ] /*replacer*/, '->' /*space*/)); // drop 'baz', use weird space print(Duktape.jsonxEnc(val, [ 'foo', 'bar', 'quux' ] /*replacer*/, '->' /*space*/)); // drop 'baz', use weird space
print(__duk__.jsoncEnc(val, ucStrings /*replacer*/, 4 /*space*/)); print(Duktape.jsoncEnc(val, ucStrings /*replacer*/, 4 /*space*/));
print(__duk__.jsoncEnc(val, [ 'foo', 'bar', 'quux' ] /*replacer*/, '->' /*space*/)); // drop 'baz', use weird space print(Duktape.jsoncEnc(val, [ 'foo', 'bar', 'quux' ] /*replacer*/, '->' /*space*/)); // drop 'baz', use weird space
} }
print('non-default encoding options'); print('non-default encoding options');
@ -633,7 +633,7 @@ BAR
function nonDefaultDecodingTest() { function nonDefaultDecodingTest() {
var val = { var val = {
foo: 'bar', foo: 'bar',
bar: __duk__.dec('hex', 'deadbeef'), bar: Duktape.dec('hex', 'deadbeef'),
quux: [ quux: [
123, 123,
0 / 0, 0 / 0,
@ -655,12 +655,12 @@ function nonDefaultDecodingTest() {
} }
enc = encJsonx(val); enc = encJsonx(val);
dec = __duk__.jsonxDec(enc, revive); dec = Duktape.jsonxDec(enc, revive);
print(Object.getOwnPropertyNames(dec)); print(Object.getOwnPropertyNames(dec));
print(dec.foo); print(dec.foo);
enc = encJsonc(val); enc = encJsonc(val);
dec = __duk__.jsoncDec(enc, revive); dec = Duktape.jsoncDec(enc, revive);
print(Object.getOwnPropertyNames(dec)); print(Object.getOwnPropertyNames(dec));
print(dec.foo); print(dec.foo);
} }
@ -707,9 +707,9 @@ function invalidXutf8Test() {
// Because standard JSON does not escape non-ASCII codepoints, hex // Because standard JSON does not escape non-ASCII codepoints, hex
// encode its output // encode its output
values.forEach(function (v) { values.forEach(function (v) {
var t = String(__duk__.dec('hex', v)); var t = String(Duktape.dec('hex', v));
print(v); print(v);
print('json ', __duk__.enc('hex', JSON.stringify(t))); print('json ', Duktape.enc('hex', JSON.stringify(t)));
print('jsonx', encJsonx(t)); print('jsonx', encJsonx(t));
print('jsonc', encJsonc(t)); print('jsonc', encJsonc(t));
}); });

38
ecmascript-testcases/test-builtin-duk.js

@ -1,5 +1,5 @@
/* /*
* __duk__ builtin. * Duktape builtin.
*/ */
/*--- /*---
@ -13,7 +13,7 @@ global
object object
function function
function function
__duk__ Duktape
string string
number number
function function
@ -46,33 +46,33 @@ function propsTest() {
print(typeof this[name]); print(typeof this[name]);
} }
function fduk(name) { function fduk(name) {
print(typeof __duk__[name]); print(typeof Duktape[name]);
} }
function fbuf(name) { function fbuf(name) {
print(typeof __duk__.Buffer[name]); print(typeof Duktape.Buffer[name]);
} }
function fbufp(name) { function fbufp(name) {
print(typeof __duk__.Buffer.prototype[name]); print(typeof Duktape.Buffer.prototype[name]);
} }
function fptr(name) { function fptr(name) {
print(typeof __duk__.Pointer[name]); print(typeof Duktape.Pointer[name]);
} }
function fptrp(name) { function fptrp(name) {
print(typeof __duk__.Pointer.prototype[name]); print(typeof Duktape.Pointer.prototype[name]);
} }
function fthr(name) { function fthr(name) {
print(typeof __duk__.Thread[name]); print(typeof Duktape.Thread[name]);
} }
function fthrp(name) { function fthrp(name) {
print(typeof __duk__.Thread.prototype[name]); print(typeof Duktape.Thread.prototype[name]);
} }
print('global'); print('global');
fglob('__duk__'); fglob('Duktape');
fglob('print'); fglob('print');
fglob('alert'); fglob('alert');
print('__duk__'); print('Duktape');
fduk('env'); fduk('env');
fduk('version'); fduk('version');
fduk('setFinalizer'); fduk('setFinalizer');
@ -145,17 +145,17 @@ function printDec(x) {
} }
function encDecTest() { function encDecTest() {
printEnc(__duk__.enc('hex', 'foo')); printEnc(Duktape.enc('hex', 'foo'));
printEnc(__duk__.enc('hex', 'foo\u1234')); printEnc(Duktape.enc('hex', 'foo\u1234'));
printDec(__duk__.dec('hex', '666f6f')); printDec(Duktape.dec('hex', '666f6f'));
printDec(__duk__.dec('hex', '666f6fe188b4')); printDec(Duktape.dec('hex', '666f6fe188b4'));
printEnc(__duk__.enc('base64', 'foo')); printEnc(Duktape.enc('base64', 'foo'));
printEnc(__duk__.enc('base64', 'foo\u1234')); printEnc(Duktape.enc('base64', 'foo\u1234'));
printDec(__duk__.dec('base64', 'Zm9v')); printDec(Duktape.dec('base64', 'Zm9v'));
printDec(__duk__.dec('base64', 'Zm9v4Yi0')); printDec(Duktape.dec('base64', 'Zm9v4Yi0'));
} }
print('encdec'); print('encdec');

20
ecmascript-testcases/test-builtin-json-enc-nonbmp.js

@ -62,19 +62,19 @@ function nonBmpTest() {
// http://en.wikipedia.org/wiki/UTF-8#Description // http://en.wikipedia.org/wiki/UTF-8#Description
// http://en.wikipedia.org/wiki/UTF-8#Extending_from_31_bit_to_36_bit_range // http://en.wikipedia.org/wiki/UTF-8#Extending_from_31_bit_to_36_bit_range
var buffers = [ var buffers = [
__duk__.dec('hex', '41'), // U+0041 (1 byte) Duktape.dec('hex', '41'), // U+0041 (1 byte)
__duk__.dec('hex', 'cca4'), // U+0324 (2 bytes) Duktape.dec('hex', 'cca4'), // U+0324 (2 bytes)
__duk__.dec('hex', 'efbb9c'), // U+FEDC (3 bytes) Duktape.dec('hex', 'efbb9c'), // U+FEDC (3 bytes)
__duk__.dec('hex', 'f48fbfbf'), // U+0010FFFF (4 bytes) Duktape.dec('hex', 'f48fbfbf'), // U+0010FFFF (4 bytes)
__duk__.dec('hex', 'f7beb78b'), // U+001FEDCB (4 bytes, above standard UTF-8) Duktape.dec('hex', 'f7beb78b'), // U+001FEDCB (4 bytes, above standard UTF-8)
__duk__.dec('hex', 'fbbfadb2ba'), // U+3FEDCBA (5 bytes) Duktape.dec('hex', 'fbbfadb2ba'), // U+3FEDCBA (5 bytes)
__duk__.dec('hex', 'fdbfbb9caea9'), // U+7FEDCBA9 (6 bytes) Duktape.dec('hex', 'fdbfbb9caea9'), // U+7FEDCBA9 (6 bytes)
__duk__.dec('hex', 'fe83beb78baa98'), // U+FEDCBA98 (7 bytes) Duktape.dec('hex', 'fe83beb78baa98'), // U+FEDCBA98 (7 bytes)
__duk__.dec('hex', 'fe83bfbfbfbfbf'), // U+FFFFFFFF (7 bytes, max value that we actually support) Duktape.dec('hex', 'fe83bfbfbfbfbf'), // U+FFFFFFFF (7 bytes, max value that we actually support)
// This is skipped as we don't support 7-byte encodings above // This is skipped as we don't support 7-byte encodings above
// unsigned 32 bit range. // unsigned 32 bit range.
//__duk__.dec('hex', 'febfbfbfbfbfbf'), // U+FFFFFFFFF (7 bytes, max for 7-byte encoding) //Duktape.dec('hex', 'febfbfbfbfbfbf'), // U+FFFFFFFFF (7 bytes, max for 7-byte encoding)
]; ];
for (i = 0; i < buffers.length; i++) { for (i = 0; i < buffers.length; i++) {

62
ecmascript-testcases/test-dev-base64-enc.js

@ -1,8 +1,8 @@
/* /*
* Some base-64 tests. * Some base-64 tests.
* *
* Note: __duk__.dec() results are coerced from buffer to string * Note: Duktape.dec() results are coerced from buffer to string
* with "'' + __duk__.dec(...)" because print() won't add an * with "'' + Duktape.dec(...)" because print() won't add an
* automatic newline if print() has only one argument which is * automatic newline if print() has only one argument which is
* a buffer. * a buffer.
*/ */
@ -25,13 +25,13 @@ Zm9vYmE=
Zm9vYmFy Zm9vYmFy
===*/ ===*/
print(__duk__.enc('base64', '')); print(Duktape.enc('base64', ''));
print(__duk__.enc('base64', 'f')); print(Duktape.enc('base64', 'f'));
print(__duk__.enc('base64', 'fo')); print(Duktape.enc('base64', 'fo'));
print(__duk__.enc('base64', 'foo')); print(Duktape.enc('base64', 'foo'));
print(__duk__.enc('base64', 'foob')); print(Duktape.enc('base64', 'foob'));
print(__duk__.enc('base64', 'fooba')); print(Duktape.enc('base64', 'fooba'));
print(__duk__.enc('base64', 'foobar')); print(Duktape.enc('base64', 'foobar'));
/*=== /*===
@ -43,13 +43,13 @@ fooba
foobar foobar
===*/ ===*/
print('' + __duk__.dec('base64', '')); print('' + Duktape.dec('base64', ''));
print('' + __duk__.dec('base64', 'Zg==')); print('' + Duktape.dec('base64', 'Zg=='));
print('' + __duk__.dec('base64', 'Zm8=')); print('' + Duktape.dec('base64', 'Zm8='));
print('' + __duk__.dec('base64', 'Zm9v')); print('' + Duktape.dec('base64', 'Zm9v'));
print('' + __duk__.dec('base64', 'Zm9vYg==')); print('' + Duktape.dec('base64', 'Zm9vYg=='));
print('' + __duk__.dec('base64', 'Zm9vYmE=')); print('' + Duktape.dec('base64', 'Zm9vYmE='));
print('' + __duk__.dec('base64', 'Zm9vYmFy')); print('' + Duktape.dec('base64', 'Zm9vYmFy'));
/*=== /*===
Zm9v4Yi0 Zm9v4Yi0
@ -59,9 +59,9 @@ Zm9v4Yi0
/* A string is UTF-8 encoded and then base-64 encoded. */ /* A string is UTF-8 encoded and then base-64 encoded. */
// U+1234 -> 0xe1 0x88 0xb4 // U+1234 -> 0xe1 0x88 0xb4
print(__duk__.enc('base64', 'foo\u1234')); print(Duktape.enc('base64', 'foo\u1234'));
t = '' + __duk__.dec('base64', 'Zm9v4Yi0'); t = '' + Duktape.dec('base64', 'Zm9v4Yi0');
print(t.charCodeAt(0), t.charCodeAt(1), t.charCodeAt(2), t.charCodeAt(3)); print(t.charCodeAt(0), t.charCodeAt(1), t.charCodeAt(2), t.charCodeAt(3));
/*=== /*===
@ -75,13 +75,13 @@ foo
* documents to be decoded (even when there is intervening padding). * documents to be decoded (even when there is intervening padding).
*/ */
t = __duk__.enc('base64', 'f') + __duk__.enc('base64', 'oo'); t = Duktape.enc('base64', 'f') + Duktape.enc('base64', 'oo');
print(t); print(t);
print('' + __duk__.dec('base64', t)); print('' + Duktape.dec('base64', t));
t = __duk__.enc('base64', 'fo') + __duk__.enc('base64', 'o'); t = Duktape.enc('base64', 'fo') + Duktape.enc('base64', 'o');
print(t); print(t);
print('' + __duk__.dec('base64', t)); print('' + Duktape.dec('base64', t));
/*=== /*===
f f
@ -95,15 +95,15 @@ fo
*/ */
try { try {
print('' + __duk__.dec('base64', 'Zg==')); // standard print('' + Duktape.dec('base64', 'Zg==')); // standard
print('' + __duk__.dec('base64', 'Zh==')); // non-zero unused bits print('' + Duktape.dec('base64', 'Zh==')); // non-zero unused bits
} catch (e) { } catch (e) {
print(e.name); print(e.name);
} }
try { try {
print('' + __duk__.dec('base64', 'Zm8=')); // standard print('' + Duktape.dec('base64', 'Zm8=')); // standard
print('' + __duk__.dec('base64', 'Zm9=')); // non-zero unused bits print('' + Duktape.dec('base64', 'Zm9=')); // non-zero unused bits
} catch (e) { } catch (e) {
print(e.name); print(e.name);
} }
@ -120,13 +120,13 @@ TypeError
*/ */
try { try {
print('' + __duk__.dec('base64', 'eHk=')); print('' + Duktape.dec('base64', 'eHk='));
} catch(e) { } catch(e) {
print(e.name); print(e.name);
} }
try { try {
print('' + __duk__.dec('base64', 'eHk')); print('' + Duktape.dec('base64', 'eHk'));
} catch(e) { } catch(e) {
print(e.name); print(e.name);
} }
@ -140,9 +140,9 @@ foo
/* The current decoder also allows ASCII whitespace characters */ /* The current decoder also allows ASCII whitespace characters */
t = __duk__.enc('base64', 'f') + '\n' + __duk__.enc('base64', 'oo') + '\n'; t = Duktape.enc('base64', 'f') + '\n' + Duktape.enc('base64', 'oo') + '\n';
print(t); print(t);
print('' + __duk__.dec('base64', t)); print('' + Duktape.dec('base64', t));
/*=== /*===
TypeError TypeError
@ -151,7 +151,7 @@ TypeError
/* Non-base64 characters will not be accepted */ /* Non-base64 characters will not be accepted */
try { try {
print('' + __duk__.dec('b28?')); print('' + Duktape.dec('b28?'));
} catch (e) { } catch (e) {
print(e.name); print(e.name);
} }

24
ecmascript-testcases/test-dev-buffer-pointer-object.js

@ -1,5 +1,5 @@
/* /*
* Simple tests for __duk__.Buffer and __duk__.Pointer and how these two * Simple tests for Duktape.Buffer and Duktape.Pointer and how these two
* custom types behave in coercions etc. More detailed tests separately. * custom types behave in coercions etc. More detailed tests separately.
*/ */
@ -21,14 +21,14 @@ foo
===*/ ===*/
function testBuffer1() { function testBuffer1() {
var plain1 = __duk__.dec('hex', 'deadbeef'); var plain1 = Duktape.dec('hex', 'deadbeef');
var plain2 = __duk__.Buffer('foo'); var plain2 = Duktape.Buffer('foo');
var object1 = new __duk__.Buffer('bar'); var object1 = new Duktape.Buffer('bar');
print(typeof plain1, dumpClass(plain1)); print(typeof plain1, dumpClass(plain1));
print(typeof plain2, dumpClass(plain2)); print(typeof plain2, dumpClass(plain2));
print(typeof object1, dumpClass(object1)); print(typeof object1, dumpClass(object1));
print(object1 instanceof __duk__.Buffer); print(object1 instanceof Duktape.Buffer);
print(typeof object1.toString()); print(typeof object1.toString());
print(typeof object1.valueOf()); print(typeof object1.valueOf());
@ -152,7 +152,7 @@ test buffer 2
===*/ ===*/
function testBuffer2() { function testBuffer2() {
var B = __duk__.Buffer; var B = Duktape.Buffer;
var values1 = [ var values1 = [
undefined, null, true, false, undefined, null, true, false,
0, 123, Number(0), Number(123), 0, 123, Number(0), Number(123),
@ -194,12 +194,12 @@ pointer
function testPointer1() { function testPointer1() {
// XXX: these yield random heap pointers now, maybe changes later // XXX: these yield random heap pointers now, maybe changes later
var plain1 = __duk__.Pointer('foo'); var plain1 = Duktape.Pointer('foo');
var object1 = new __duk__.Pointer('bar'); var object1 = new Duktape.Pointer('bar');
print(typeof plain1, dumpClass(plain1)); print(typeof plain1, dumpClass(plain1));
print(typeof object1, dumpClass(object1)); print(typeof object1, dumpClass(object1));
print(object1 instanceof __duk__.Pointer); print(object1 instanceof Duktape.Pointer);
print(typeof object1.toString()); print(typeof object1.toString());
print(typeof object1.valueOf()); print(typeof object1.valueOf());
@ -208,8 +208,8 @@ function testPointer1() {
print(typeof plain1.toString()); print(typeof plain1.toString());
print(typeof plain1.valueOf()); print(typeof plain1.valueOf());
var ptr_null = __duk__.Pointer(); var ptr_null = Duktape.Pointer();
var ptr_nonnull = __duk__.Pointer('foo'); var ptr_nonnull = Duktape.Pointer('foo');
// unary plus coercion is ToNumber() // unary plus coercion is ToNumber()
print(+ptr_null, +ptr_nonnull); print(+ptr_null, +ptr_nonnull);
@ -265,7 +265,7 @@ test pointer 2
===*/ ===*/
function testPointer2() { function testPointer2() {
var P = __duk__.Pointer; var P = Duktape.Pointer;
var p1 = P(); // NULL var p1 = P(); // NULL
var p2 = P('foo'); // non-NULL var p2 = P('foo'); // non-NULL
var values1 = [ var values1 = [

2
ecmascript-testcases/test-dev-bug-finalizer-rescue.js

@ -14,7 +14,7 @@ object
a={}; a={};
// The finalizer rescues the reference (= makes it reachable again) // The finalizer rescues the reference (= makes it reachable again)
__duk__.setFinalizer(a, function(x) { print('finalizer'); a=x }); Duktape.setFinalizer(a, function(x) { print('finalizer'); a=x });
a = null; a = null;
print(typeof a); print(typeof a);

6
ecmascript-testcases/test-dev-bug-stringtable-leak.js

@ -75,7 +75,7 @@ function test1() {
print(i); print(i);
for (var j = 0; j < 1024; j++) { for (var j = 0; j < 1024; j++) {
var ignore = createUniqueString(); var ignore = createUniqueString();
__duk__.gc(); Duktape.gc();
} }
} }
} }
@ -87,10 +87,10 @@ function test2() {
var obj1 = {}; var obj1 = {};
var obj2 = { str: createUniqueString(), ref: obj1 }; var obj2 = { str: createUniqueString(), ref: obj1 };
obj1.ref = obj2; // circular reference, object contains string to collect obj1.ref = obj2; // circular reference, object contains string to collect
__duk__.gc(); // force collection once: string gets marked reachable Duktape.gc(); // force collection once: string gets marked reachable
obj1 = undefined; obj1 = undefined;
obj2 = undefined; // unreachable but not collected when refcounts enabled obj2 = undefined; // unreachable but not collected when refcounts enabled
__duk__.gc(); // force collection: should be collected but isn't Duktape.gc(); // force collection: should be collected but isn't
} }
} }
} }

12
ecmascript-testcases/test-dev-bug-throw-in-catch.js

@ -26,7 +26,7 @@ finished
===*/ ===*/
function yielder(x) { function yielder(x) {
var yield = __duk__.Thread.yield; var yield = Duktape.Thread.yield;
print('yielder starting'); print('yielder starting');
print('yielder arg:', x); print('yielder arg:', x);
@ -53,14 +53,14 @@ function yielder(x) {
return 123; return 123;
} }
var t = new __duk__.Thread(yielder); var t = new Duktape.Thread(yielder);
try { try {
print('resume tests'); print('resume tests');
print('yielded with', __duk__.Thread.resume(t, 'foo')); print('yielded with', Duktape.Thread.resume(t, 'foo'));
print('yielded with', __duk__.Thread.resume(t, 'bar')); print('yielded with', Duktape.Thread.resume(t, 'bar'));
print('yielded with', __duk__.Thread.resume(t, 'quux')); print('yielded with', Duktape.Thread.resume(t, 'quux'));
print('yielded with', __duk__.Thread.resume(t, 'baz')); print('yielded with', Duktape.Thread.resume(t, 'baz'));
} catch (e) { } catch (e) {
print(e); print(e);
} }

2
ecmascript-testcases/test-dev-builtin-name-props.js

@ -130,7 +130,7 @@ undefined
/* FIXME: other non-standard builtins */ /* FIXME: other non-standard builtins */
try { try {
print(__duk__.name); print(Duktape.name);
} catch (e) { } catch (e) {
print(e.name); print(e.name);
} }

12
ecmascript-testcases/test-dev-coroutine-basic.js

@ -20,7 +20,7 @@ finished
===*/ ===*/
function yielder(x) { function yielder(x) {
var yield = __duk__.Thread.yield; var yield = Duktape.Thread.yield;
print('yielder starting'); print('yielder starting');
print('yielder arg:', x); print('yielder arg:', x);
@ -33,13 +33,13 @@ function yielder(x) {
return 123; return 123;
} }
var t = new __duk__.Thread(yielder); var t = new Duktape.Thread(yielder);
print('resume tests'); print('resume tests');
print('yielded with', __duk__.Thread.resume(t, 'foo')); print('yielded with', Duktape.Thread.resume(t, 'foo'));
print('yielded with', __duk__.Thread.resume(t, 'bar')); print('yielded with', Duktape.Thread.resume(t, 'bar'));
print('yielded with', __duk__.Thread.resume(t, 'quux')); print('yielded with', Duktape.Thread.resume(t, 'quux'));
print('yielded with', __duk__.Thread.resume(t, 'baz')); print('yielded with', Duktape.Thread.resume(t, 'baz'));
print('finished'); print('finished');

4
ecmascript-testcases/test-dev-hex-enc.js

@ -12,8 +12,8 @@ var t;
102 111 111 4660 102 111 111 4660
===*/ ===*/
print(__duk__.enc('hex', 'foo\u1234')); print(Duktape.enc('hex', 'foo\u1234'));
t = '' + __duk__.dec('hex', '666f6fe188b4'); t = '' + Duktape.dec('hex', '666f6fe188b4');
print(t.charCodeAt(0), t.charCodeAt(1), t.charCodeAt(2), t.charCodeAt(3)); print(t.charCodeAt(0), t.charCodeAt(1), t.charCodeAt(2), t.charCodeAt(3));

4
ecmascript-testcases/test-dev-markandsweep-finalizer-1.js

@ -26,7 +26,7 @@ function init() {
a = { foo: 123 }; a = { foo: 123 };
b = {} b = {}
__duk__.setFinalizer(a, function (x) { Duktape.setFinalizer(a, function (x) {
print('finalizer, foo ->', x.foo); print('finalizer, foo ->', x.foo);
}); });
@ -44,5 +44,5 @@ b = null;
print('nulled') print('nulled')
// mark-and-sweep finalizing happens here if refcount disabled // mark-and-sweep finalizing happens here if refcount disabled
__duk__.gc(); Duktape.gc();

18
ecmascript-testcases/test-dev-markandsweep-finalizer-2.js

@ -65,8 +65,8 @@ function init() {
a.ref = b; a.ref = b;
b.ref = a; b.ref = a;
__duk__.setFinalizer(a, finalizer_a); Duktape.setFinalizer(a, finalizer_a);
__duk__.setFinalizer(b, finalizer_b); Duktape.setFinalizer(b, finalizer_b);
} }
function delrefs() { function delrefs() {
@ -78,8 +78,8 @@ function testrefs() {
print(typeof a); print(typeof a);
print(typeof b); print(typeof b);
//print(__duk__.refc(a)); //print(Duktape.refc(a));
//print(__duk__.refc(b)); //print(Duktape.refc(b));
} }
init(); init();
@ -88,8 +88,8 @@ testrefs();
rescue = true; rescue = true;
delrefs(); delrefs();
__duk__.gc(); // both a and b should be unreachable and have their finalizers executed Duktape.gc(); // both a and b should be unreachable and have their finalizers executed
__duk__.gc(); // a second gc will rescue the objects, allowing their finalizer to run again Duktape.gc(); // a second gc will rescue the objects, allowing their finalizer to run again
testrefs(); testrefs();
/* Note: a single gc above is NOT sufficient to ensure that the finalizer will run again. /* Note: a single gc above is NOT sufficient to ensure that the finalizer will run again.
@ -111,12 +111,12 @@ testrefs();
rescue = true; rescue = true;
delrefs(); delrefs();
__duk__.gc(); // again Duktape.gc(); // again
__duk__.gc(); Duktape.gc();
testrefs(); testrefs();
rescue = false; rescue = false;
delrefs(); delrefs();
__duk__.gc(); // swept immediately Duktape.gc(); // swept immediately
testrefs(); testrefs();

8
ecmascript-testcases/test-dev-markandsweep-finalizer-3.js

@ -21,7 +21,7 @@ bar
var newobj = null; var newobj = null;
var obj1 = { name: 'obj1' }; var obj1 = { name: 'obj1' };
__duk__.setFinalizer(obj1, function (o) { Duktape.setFinalizer(obj1, function (o) {
print('finalizer', o.name); print('finalizer', o.name);
newobj = { foo: 'bar' }; newobj = { foo: 'bar' };
}); });
@ -35,14 +35,14 @@ obj2 = null;
print('obj1 and obj2 unreachable now'); print('obj1 and obj2 unreachable now');
print('forced gc'); print('forced gc');
__duk__.gc(); // finalizer executes and creates 'newobj' Duktape.gc(); // finalizer executes and creates 'newobj'
print(newobj.foo); print(newobj.foo);
print('forced gc'); print('forced gc');
__duk__.gc(); // 'newobj' survives collection Duktape.gc(); // 'newobj' survives collection
print(newobj.foo); print(newobj.foo);
print('forced gc'); print('forced gc');
__duk__.gc(); Duktape.gc();
print(newobj.foo); print(newobj.foo);

4
ecmascript-testcases/test-dev-markandsweep-finalizer-4.js

@ -17,8 +17,8 @@ function fin(o) {
var obj1 = { name: 'obj1' }; var obj1 = { name: 'obj1' };
var obj2 = { name: 'obj2' }; var obj2 = { name: 'obj2' };
__duk__.setFinalizer(obj1, fin); Duktape.setFinalizer(obj1, fin);
__duk__.setFinalizer(obj2, fin); Duktape.setFinalizer(obj2, fin);
obj1.ref = obj2; // use circular reference to prevent refcount collection obj1.ref = obj2; // use circular reference to prevent refcount collection
obj2.ref = obj1; obj2.ref = obj1;
obj1 = null; obj1 = null;

4
ecmascript-testcases/test-dev-refcount-finalizer-1.js

@ -17,7 +17,7 @@ var a;
function init() { function init() {
a = { foo: 123 }; a = { foo: 123 };
__duk__.setFinalizer(a, function (x) { Duktape.setFinalizer(a, function (x) {
print('finalizer, foo ->', x.foo); print('finalizer, foo ->', x.foo);
}); });
} }
@ -28,5 +28,5 @@ init();
a = null; a = null;
// mark-and-sweep finalizing happens here if refcount disabled // mark-and-sweep finalizing happens here if refcount disabled
__duk__.gc(); Duktape.gc();

8
ecmascript-testcases/test-dev-refcount-finalizer-2.js

@ -19,8 +19,8 @@ var func1 = function(x) { print("Finalizer's finalizer"); };
var func2 = function(x) { print("Finalizer"); obj = x; /*rescue*/ }; var func2 = function(x) { print("Finalizer"); obj = x; /*rescue*/ };
var obj = {}; var obj = {};
__duk__.setFinalizer(obj, func2); Duktape.setFinalizer(obj, func2);
__duk__.setFinalizer(func2, func1); Duktape.setFinalizer(func2, func1);
func1 = null; func1 = null;
func2 = null; func2 = null;
@ -37,11 +37,11 @@ print(typeof obj);
// closure is by default participates in a reference loop through // closure is by default participates in a reference loop through
// its automatic prototype (e.g. f.prototype.constructor === f). // its automatic prototype (e.g. f.prototype.constructor === f).
__duk__.setFinalizer(obj, null); Duktape.setFinalizer(obj, null);
// Explicit GC causes the finalizer's finalizer to run. // Explicit GC causes the finalizer's finalizer to run.
__duk__.gc(); Duktape.gc();
obj = undefined; obj = undefined;
print(typeof obj); print(typeof obj);

2
ecmascript-testcases/test-dev-refcount-finalizer-3.js

@ -31,7 +31,7 @@ function finalizer(x) {
} }
} }
__duk__.setFinalizer(o, finalizer); Duktape.setFinalizer(o, finalizer);
rescue = true; rescue = true;
o = undefined; // refzero, finalize, gets rescued o = undefined; // refzero, finalize, gets rescued

10
ecmascript-testcases/test-dev-yield-after-callapply.js

@ -12,7 +12,7 @@ var res;
*/ */
function innerfunc() { function innerfunc() {
__duk__.Thread.yield(123); Duktape.Thread.yield(123);
} }
function coroutine1() { function coroutine1() {
@ -26,16 +26,16 @@ function coroutine2() {
} }
try { try {
thread = new __duk__.Thread(coroutine1); thread = new Duktape.Thread(coroutine1);
res = __duk__.Thread.resume(thread, 0); res = Duktape.Thread.resume(thread, 0);
print(res); print(res);
} catch (e) { } catch (e) {
print(e.name); print(e.name);
} }
try { try {
thread = new __duk__.Thread(coroutine2); thread = new Duktape.Thread(coroutine2);
res = __duk__.Thread.resume(thread, 0); res = Duktape.Thread.resume(thread, 0);
print(res); print(res);
} catch (e) { } catch (e) {
print(e.name); print(e.name);

8
ecmascript-testcases/test-dev-yield-from-constructor.js

@ -11,7 +11,7 @@ TypeError
var thr; var thr;
function Foo() { function Foo() {
__duk__.Thread.yield(123); Duktape.Thread.yield(123);
} }
function coroutine() { function coroutine() {
@ -21,9 +21,9 @@ function coroutine() {
} }
try { try {
thr = new __duk__.Thread(coroutine); thr = new Duktape.Thread(coroutine);
print(__duk__.Thread.resume(thr)); print(Duktape.Thread.resume(thr));
print(__duk__.Thread.resume(thr)); print(Duktape.Thread.resume(thr));
} catch (e) { } catch (e) {
print(e.name); print(e.name);
} }

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

@ -8,10 +8,10 @@ TypeError
===*/ ===*/
function test_eval() { function test_eval() {
var t = new __duk__.Thread(function() { var t = new Duktape.Thread(function() {
eval('__duk__.Thread.yield(1234)'); eval('Duktape.Thread.yield(1234)');
}); });
__duk__.Thread.resume(t) Duktape.Thread.resume(t)
} }
try { try {

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

@ -9,11 +9,11 @@ TypeError
===*/ ===*/
function getter() { function getter() {
__duk__.Thread.yield('foo') Duktape.Thread.yield('foo')
} }
function setter() { function setter() {
__duk__.Thread.yield('bar') Duktape.Thread.yield('bar')
} }
var obj = { var obj = {
@ -22,18 +22,18 @@ var obj = {
} }
function test_get() { function test_get() {
var t = new __duk__.Thread(function() { var t = new Duktape.Thread(function() {
print(obj.a); print(obj.a);
}); });
__duk__.Thread.resume(t) Duktape.Thread.resume(t)
} }
function test_set() { function test_set() {
var t = new __duk__.Thread(function() { var t = new Duktape.Thread(function() {
obj.a = 1; obj.a = 1;
print('setter ok'); print('setter ok');
}); });
__duk__.Thread.resume(t) Duktape.Thread.resume(t)
} }
try { try {

4
ecmascript-testcases/test-misc-pointer-tostring.js

@ -15,8 +15,8 @@ true
*/ */
function pointerTostringTest() { function pointerTostringTest() {
var ptr_null = __duk__.Pointer(); var ptr_null = Duktape.Pointer();
var ptr_nonnull = __duk__.Pointer('dummy'); var ptr_nonnull = Duktape.Pointer('dummy');
var re_ptr_nonnull = /^[0-9a-fA-Fx:]+$/; var re_ptr_nonnull = /^[0-9a-fA-Fx:]+$/;
print(ptr_null.toString()); print(ptr_null.toString());

Loading…
Cancel
Save