Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2012-01-17 19:20:37 +0400
committerBen Noordhuis <info@bnoordhuis.nl>2012-01-17 19:20:39 +0400
commit549443a7cc600e93cc1d1d1630108e7d0a035500 (patch)
treef8ac17f3108737c45ef6d7e5422c56c346386d48 /test
parent25410096b4c38eb9b17501ea06349872ab33e1ea (diff)
typed arrays: set class name
Make obj.toString and Object.prototype.toString work correctly for typed arrays.
Diffstat (limited to 'test')
-rw-r--r--test/simple/test-typed-arrays-typenames.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/simple/test-typed-arrays-typenames.js b/test/simple/test-typed-arrays-typenames.js
new file mode 100644
index 00000000000..a78c7598acb
--- /dev/null
+++ b/test/simple/test-typed-arrays-typenames.js
@@ -0,0 +1,48 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var common = require('../common');
+var assert = require('assert');
+
+// TODO: merge with test-typed-arrays.js some time in the future.
+// That file only exists in master right now.
+[
+ 'ArrayBuffer',
+ 'Int8Array',
+ 'Uint8Array',
+ 'Int16Array',
+ 'Uint16Array',
+ 'Int32Array',
+ 'Uint32Array',
+ 'Float32Array',
+ 'Float64Array'
+].forEach(function(name) {
+ var expected = '[object ' + name + ']';
+ var clazz = global[name];
+ var obj = new clazz(1);
+
+ assert.equal(obj.toString(), expected);
+ assert.equal(Object.prototype.toString.call(obj), expected);
+
+ obj = new DataView(obj);
+ assert.equal(obj.toString(), '[object DataView]');
+ assert.equal(Object.prototype.toString.call(obj), '[object DataView]');
+});