Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1448)

Unified Diff: test/mjsunit/harmony/typedarrays.js

Issue 21924007: Make new Harmony constructors subclassing-friendly (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/runtime.cc ('K') | « test/mjsunit/harmony/collections.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/typedarrays.js
diff --git a/test/mjsunit/harmony/typedarrays.js b/test/mjsunit/harmony/typedarrays.js
index c6d130fc0c6dd30268e0a6ca3c2088bf16d2fbaa..1095345f61f49330a5b183a5ca932d4170ce5e15 100644
--- a/test/mjsunit/harmony/typedarrays.js
+++ b/test/mjsunit/harmony/typedarrays.js
@@ -24,6 +24,8 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Flags: --allow-natives-syntax
// ArrayBuffer
@@ -559,7 +561,7 @@ for(i = 0; i < typedArrayConstructors.lenght; i++) {
}
TestEnumerable(DataView, new DataView(new ArrayBuffer()));
-// Test arbitrary properties on ArrayBuffer
+// Test arbitrary properties on ArrayBuffer and DataView
function TestArbitrary(m) {
function TestProperty(map, property, value) {
map[property] = value;
@@ -571,12 +573,50 @@ function TestArbitrary(m) {
}
}
TestArbitrary(new ArrayBuffer(256));
-for(i = 0; i < typedArrayConstructors.lenght; i++) {
- TestArbitary(new typedArrayConstructors[i](10));
-}
TestArbitrary(new DataView(new ArrayBuffer(256)));
+// Test arbitrary properties on TypedArrays
+function TestArbitraryNonIndexed(m) {
+ function TestProperty(map, property, value) {
+ map[property] = value;
+ assertEquals(value, map[property]);
+ }
+ for (var i = 0; i < 20; i++) {
+ TestProperty(m, 'foo' + i, 'bar' + i);
+ }
+}
+for(i = 0; i < typedArrayConstructors.length; i++) {
+ TestArbitraryNonIndexed(new typedArrayConstructors[i](10));
+}
+
// Test direct constructor call
assertThrows(function() { ArrayBuffer(); }, TypeError);
assertThrows(function() { DataView(new ArrayBuffer()); }, TypeError);
+
+// Test that constructor can be called only on appropriate objects only once.
+function TestConstructorBehavior(C) {
+ var obj = new C();
+ assertThrows(function() { C.call(obj); }, TypeError);
+ assertThrows(function() { C.call({}); }, TypeError);
+ var uninitObj = %NewObject(C);
+ C.call(uninitObj); // shouldn't throw
+}
+
+TestConstructorBehavior(ArrayBuffer);
+for(i = 0; i < typedArrayConstructors.length; i++) {
+ TestConstructorBehavior(typedArrayConstructors[i]);
+}
+
+
+// Test that DataView constructor can be called only on appropriate objects
+// only once.
+function TestDataViewConstructorBehavior() {
+ var ab = new ArrayBuffer(100);
+ var obj = new DataView(ab);
+ assertThrows(function() { DataView.call(obj, ab); }, TypeError);
+ assertThrows(function() { DataView.call({}, ab); }, TypeError);
+ var uninitObj = %NewObject(DataView);
+ DataView.call(uninitObj, ab); // shouldn't throw
+}
+TestDataViewConstructorBehavior();
« src/runtime.cc ('K') | « test/mjsunit/harmony/collections.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698