~ubuntu-branches/ubuntu/saucy/libv8/saucy

« back to all changes in this revision

Viewing changes to test/mjsunit/external-array.js

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2012-04-07 16:26:13 UTC
  • mfrom: (15.1.27 sid)
  • Revision ID: package-import@ubuntu.com-20120407162613-dqo1m6w9r3fh8tst
Tags: 3.8.9.16-3
* mipsel build fixes :
  + v8_use_mips_abi_hardfloat=false, this lowers EABI requirements.
  + v8_can_use_fpu_instructions=false, detect if FPU is present.
  + set -Wno-unused-but-set-variable only on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2011 the V8 project authors. All rights reserved.
 
1
// Copyright 2012 the V8 project authors. All rights reserved.
2
2
// Redistribution and use in source and binary forms, with or without
3
3
// modification, are permitted provided that the following conditions are
4
4
// met:
43
43
assertEquals(0, a[0]);
44
44
assertEquals(0, a[1]);
45
45
 
 
46
// No-parameter constructor should fail right now.
 
47
function abfunc1() {
 
48
  return new ArrayBuffer();
 
49
}
 
50
assertThrows(abfunc1);
 
51
 
 
52
// Test derivation from an ArrayBuffer
 
53
var ab = new ArrayBuffer(12);
 
54
var derived_uint8 = new Uint8Array(ab);
 
55
assertEquals(12, derived_uint8.length);
 
56
var derived_uint32 = new Uint32Array(ab);
 
57
assertEquals(3, derived_uint32.length);
 
58
var derived_uint32_2 = new Uint32Array(ab,4);
 
59
assertEquals(2, derived_uint32_2.length);
 
60
var derived_uint32_3 = new Uint32Array(ab,4,1);
 
61
assertEquals(1, derived_uint32_3.length);
 
62
 
 
63
// If a given byteOffset and length references an area beyond the end of the
 
64
// ArrayBuffer an exception is raised.
 
65
function abfunc3() {
 
66
  new Uint32Array(ab,4,3);
 
67
}
 
68
assertThrows(abfunc3);
 
69
function abfunc4() {
 
70
  new Uint32Array(ab,16);
 
71
}
 
72
assertThrows(abfunc4);
 
73
 
 
74
// The given byteOffset must be a multiple of the element size of the specific
 
75
// type, otherwise an exception is raised.
 
76
function abfunc5() {
 
77
  new Uint32Array(ab,5);
 
78
}
 
79
assertThrows(abfunc5);
 
80
 
 
81
// If length is not explicitly specified, the length of the ArrayBuffer minus
 
82
// the byteOffset must be a multiple of the element size of the specific type,
 
83
// or an exception is raised.
 
84
var ab2 = new ArrayBuffer(13);
 
85
function abfunc6() {
 
86
  new Uint32Array(ab2,4);
 
87
}
 
88
assertThrows(abfunc6);
 
89
 
46
90
// Test the correct behavior of the |BYTES_PER_ELEMENT| property (which is
47
91
// "constant", but not read-only).
48
92
a = new Int32Array(2);