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

Side by Side Diff: LayoutTests/fast/canvas/webgl/array-unit-tests.html

Issue 11747006: Merge 138393 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1364/
Patch Set: Created 7 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/canvas/webgl/array-unit-tests-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script src="../../js/resources/js-test-pre.js"></script> 3 <script src="../../js/resources/js-test-pre.js"></script>
4 <script src="resources/webgl-test.js"></script> 4 <script src="resources/webgl-test.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <div id="description"></div> 7 <div id="description"></div>
8 <div id="console"></div> 8 <div id="console"></div>
9 9
10 <script> 10 <script>
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 function test(subBuf, starts, size) { 63 function test(subBuf, starts, size) {
64 byteLength = size; 64 byteLength = size;
65 subBuffer = eval(subBuf); 65 subBuffer = eval(subBuf);
66 var subArray = new Int8Array(subBuffer); 66 var subArray = new Int8Array(subBuffer);
67 assertEq(subBuf, subBuffer.byteLength, byteLength); 67 assertEq(subBuf, subBuffer.byteLength, byteLength);
68 for (var i = 0; i < size; ++i) 68 for (var i = 0; i < size; ++i)
69 assertEq('Element ' + i, starts + i, subArray[i]); 69 assertEq('Element ' + i, starts + i, subArray[i]);
70 } 70 }
71 71
72 try { 72 try {
73 running('testSlice');
73 var buffer = new ArrayBuffer(32); 74 var buffer = new ArrayBuffer(32);
74 var array = new Int8Array(buffer); 75 var array = new Int8Array(buffer);
75 for (var i = 0; i < 32; ++i) 76 for (var i = 0; i < 32; ++i)
76 array[i] = i; 77 array[i] = i;
77 78
78 test("buffer.slice(0)", 0, 32); 79 test("buffer.slice(0)", 0, 32);
79 test("buffer.slice(16)", 16, 16); 80 test("buffer.slice(16)", 16, 16);
80 test("buffer.slice(24)", 24, 8); 81 test("buffer.slice(24)", 24, 8);
81 test("buffer.slice(32)", 32, 0); 82 test("buffer.slice(32)", 32, 0);
82 test("buffer.slice(40)", 32, 0); 83 test("buffer.slice(40)", 32, 0);
(...skipping 12 matching lines...) Expand all
95 test("buffer.slice(16, 32)", 16, 16); 96 test("buffer.slice(16, 32)", 16, 16);
96 test("buffer.slice(24, 16)", 24, 0); 97 test("buffer.slice(24, 16)", 24, 0);
97 98
98 test("buffer.slice(16, -8)", 16, 8); 99 test("buffer.slice(16, -8)", 16, 8);
99 test("buffer.slice(-20, 30)", 12, 18); 100 test("buffer.slice(-20, 30)", 12, 18);
100 101
101 test("buffer.slice(-8, -20)", 24, 0); 102 test("buffer.slice(-8, -20)", 24, 0);
102 test("buffer.slice(-20, -8)", 12, 12); 103 test("buffer.slice(-20, -8)", 12, 12);
103 test("buffer.slice(-40, 16)", 0, 16); 104 test("buffer.slice(-40, 16)", 0, 16);
104 test("buffer.slice(-40, 40)", 0, 32); 105 test("buffer.slice(-40, 40)", 0, 32);
106 pass();
105 } catch (e) { 107 } catch (e) {
106 fail(e); 108 fail(e);
107 } 109 }
108 } 110 }
109 111
110 // 112 //
111 // Tests for unsigned array variants 113 // Tests for unsigned array variants
112 // 114 //
113 115
114 function testSetAndGet10To1(type, name) { 116 function testSetAndGet10To1(type, name) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 // to exercise all of their optimized code paths. 213 // to exercise all of their optimized code paths.
212 // 214 //
213 215
214 function testIntegralArrayTruncationBehavior(type, name, unsigned) { 216 function testIntegralArrayTruncationBehavior(type, name, unsigned) {
215 running('test integral array truncation behavior for ' + name); 217 running('test integral array truncation behavior for ' + name);
216 218
217 var sourceData; 219 var sourceData;
218 var expectedResults; 220 var expectedResults;
219 221
220 if (unsigned) { 222 if (unsigned) {
221 sourceData = [0.6, 10.6]; 223 sourceData = [0.6, 10.6, 0.2, 10.2, 10.5, 11.5];
222 if (type === Uint8ClampedArray) { 224 if (type === Uint8ClampedArray) {
223 expectedResults = [1, 11]; 225 expectedResults = [1, 11, 0, 10, 10, 12];
224 } else { 226 } else {
225 expectedResults = [0, 10]; 227 expectedResults = [0, 10, 0, 10, 10, 11];
226 } 228 }
227 } else { 229 } else {
228 sourceData = [0.6, 10.6, -0.6, -10.6]; 230 sourceData = [0.6, 10.6, -0.6, -10.6];
229 expectedResults = [0, 10, 0, -10]; 231 expectedResults = [0, 10, 0, -10];
230 } 232 }
231 233
232 var numIterations = 10; 234 var numIterations = 10;
233 var array = new type(numIterations); 235 var array = new type(numIterations);
234 236
235 // The code block in each of the case statements below is identical, but some 237 // The code block in each of the case statements below is identical, but some
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 function shouldThrowIndexSizeErr(func, text) { 547 function shouldThrowIndexSizeErr(func, text) {
546 var errorText = text + " should throw an exception"; 548 var errorText = text + " should throw an exception";
547 try { 549 try {
548 func(); 550 func();
549 testFailed(errorText); 551 testFailed(errorText);
550 } catch (e) { 552 } catch (e) {
551 testPassed(text + " threw an exception"); 553 testPassed(text + " threw an exception");
552 } 554 }
553 } 555 }
554 556
557 function shouldThrowTypeError(func, text) {
558 var ok = false;
559 try {
560 func();
561 } catch (e) {
562 if (e instanceof TypeError) {
563 ok = true;
564 }
565 }
566 if (ok) {
567 testPassed(text + " threw TypeError");
568 } else {
569 testFailed(text + " should throw TypeError");
570 }
571 }
572
555 function testConstructionWithOutOfRangeValues(type, name) { 573 function testConstructionWithOutOfRangeValues(type, name) {
556 shouldThrowIndexSizeErr(function() { 574 shouldThrowIndexSizeErr(function() {
557 var buffer = new ArrayBuffer(4); 575 var buffer = new ArrayBuffer(4);
558 var array = new type(buffer, 4, 0x3FFFFFFF); 576 var array = new type(buffer, 4, 0x3FFFFFFF);
559 }, "Construction of " + name + " with out-of-range number of elements"); 577 }, "Construction of " + name + " with out-of-range number of elements");
560 shouldThrowIndexSizeErr(function() { 578 shouldThrowIndexSizeErr(function() {
561 var buffer = new ArrayBuffer(4); 579 var buffer = new ArrayBuffer(4);
562 var array = new type(buffer, 8); 580 var array = new type(buffer, 8);
563 }, "Construction of " + name + " with out-of-range offset"); 581 }, "Construction of " + name + " with out-of-range offset");
564 } 582 }
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 for (var i = 0; i < array.length; ++i) 912 for (var i = 0; i < array.length; ++i)
895 assertEq('NaN converted to zero by setter', 0, results[i]); 913 assertEq('NaN converted to zero by setter', 0, results[i]);
896 } 914 }
897 915
898 pass(); 916 pass();
899 } catch (e) { 917 } catch (e) {
900 fail(e); 918 fail(e);
901 } 919 }
902 } 920 }
903 921
922 function testInheritanceHierarchy() {
923 debug('test inheritance hierarchy of typed array views');
924
925 try {
926 var foo = ArrayBufferView;
927 testPassed('ArrayBufferView does not have [NoInterfaceObject] extended attri bute and should be defined');
928
929 shouldBe('new Int8Array(1) instanceof ArrayBufferView', 'true');
930 shouldBe('new Uint8Array(1) instanceof ArrayBufferView', 'true');
931 shouldBe('new Uint8ClampedArray(1) instanceof ArrayBufferView', 'true');
932 shouldBe('new Int16Array(1) instanceof ArrayBufferView', 'true');
933 shouldBe('new Uint16Array(1) instanceof ArrayBufferView', 'true');
934 shouldBe('new Int32Array(1) instanceof ArrayBufferView', 'true');
935 shouldBe('new Uint32Array(1) instanceof ArrayBufferView', 'true');
936 shouldBe('new Float32Array(1) instanceof ArrayBufferView', 'true');
937 shouldBe('new Float64Array(1) instanceof ArrayBufferView', 'true');
938 shouldBe('new DataView(new ArrayBuffer(8)) instanceof ArrayBufferView', 'tru e');
939
940 shouldThrowTypeError(function() { new ArrayBufferView() }, "new ArrayBufferV iew()");
941 } catch (e) {
942 testFailed('ArrayBufferView does not have [NoInterfaceObject] extended attri bute but was not defined');
943 }
944
945 // There is currently only one kind of view that inherits from another
946 shouldBe('new Uint8ClampedArray(1) instanceof Uint8Array', 'true');
947 }
948
949
904 // 950 //
905 // Test driver 951 // Test driver
906 // 952 //
907 953
908 function runTests() { 954 function runTests() {
909 allPassed = true; 955 allPassed = true;
910 956
911 testSlice(); 957 testSlice();
958 testInheritanceHierarchy();
912 959
913 // The "name" attribute is a concession to browsers which don't 960 // The "name" attribute is a concession to browsers which don't
914 // implement the "name" property on function objects 961 // implement the "name" property on function objects
915 var testCases = 962 var testCases =
916 [ {name: "Float32Array", 963 [ {name: "Float32Array",
917 unsigned: false, 964 unsigned: false,
918 integral: false, 965 integral: false,
919 elementSizeInBytes: 4, 966 elementSizeInBytes: 4,
920 testValues: [ -500.5, 500.5 ], 967 testValues: [ -500.5, 500.5 ],
921 expectedValues: [ -500.5, 500.5 ] 968 expectedValues: [ -500.5, 500.5 ]
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 printSummary(); 1090 printSummary();
1044 } 1091 }
1045 1092
1046 runTests(); 1093 runTests();
1047 1094
1048 </script> 1095 </script>
1049 <script src="../../js/resources/js-test-post.js"></script> 1096 <script src="../../js/resources/js-test-post.js"></script>
1050 1097
1051 </body> 1098 </body>
1052 </html> 1099 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/canvas/webgl/array-unit-tests-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698