mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
768 B
44 lines
768 B
10 years ago
|
/*
|
||
|
* Duktape Node.js Buffer virtual properties don't work in
|
||
|
* Object.defineProperty().
|
||
|
*/
|
||
|
|
||
|
/*---
|
||
|
{
|
||
|
"custom": true
|
||
|
}
|
||
|
---*/
|
||
|
|
||
|
/*===
|
||
|
object 8 testdata
|
||
|
100
|
||
|
TypeError
|
||
|
100
|
||
|
object 8 testdata
|
||
|
===*/
|
||
|
|
||
|
function test() {
|
||
|
var buf = new Buffer('testdata');
|
||
|
print(typeof buf, buf.length, String(buf));
|
||
|
|
||
|
print(buf[4]);
|
||
|
try {
|
||
|
Object.defineProperty(buf, '4', {
|
||
|
value: 68
|
||
|
});
|
||
|
} catch (e) {
|
||
|
// Duktape: TypeError: property is virtual
|
||
|
// Node.js: TypeError: Cannot redefine a property of an object with external array elements
|
||
|
print(e.name);
|
||
|
//print(e.stack || e);
|
||
|
}
|
||
|
print(buf[4]);
|
||
|
print(typeof buf, buf.length, String(buf));
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
test();
|
||
|
} catch (e) {
|
||
|
print(e.stack || e);
|
||
|
}
|