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

Unified Diff: test/codegen/lib/html/typed_arrays_simd_test.dart

Issue 1930043002: Add all dart:html tests from the sdk to test/codegen. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: ptal Created 4 years, 8 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
« no previous file with comments | « test/codegen/lib/html/typed_arrays_range_checks_test.dart ('k') | test/codegen/lib/html/typing_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/lib/html/typed_arrays_simd_test.dart
diff --git a/test/codegen/lib/html/typed_arrays_simd_test.dart b/test/codegen/lib/html/typed_arrays_simd_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..0e3d780f3fb5522a0ca919734b341e3dc41a869a
--- /dev/null
+++ b/test/codegen/lib/html/typed_arrays_simd_test.dart
@@ -0,0 +1,85 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library TypedArraysSimdTest;
+import 'package:unittest/unittest.dart';
+import 'package:unittest/html_config.dart';
+import 'dart:html';
+import 'dart:typed_data';
+
+const _FLOATING_POINT_ERROR = 0.0000000001;
+floatEquals(value) => closeTo(value, _FLOATING_POINT_ERROR);
+
+class MyFloat32x4 {
+ num x = 0.0;
+ num y = 0.0;
+ num z = 0.0;
+ num w = 0.0;
+}
+
+main() {
+ useHtmlConfiguration();
+
+ // Only perform tests if ArrayBuffer is supported.
+ if (!Platform.supportsTypedData) {
+ return;
+ }
+
+ test('test Float32x4', () {
+ if (Platform.supportsSimd) {
+ final val = new Float32x4(1.0, 2.0, 3.0, 4.0);
+ expect(val.x, floatEquals(1.0));
+ expect(val.y, floatEquals(2.0));
+ expect(val.z, floatEquals(3.0));
+ expect(val.w, floatEquals(4.0));
+ final val2 = val + val;
+ expect(val2.x, floatEquals(2.0));
+ expect(val2.y, floatEquals(4.0));
+ expect(val2.z, floatEquals(6.0));
+ expect(val2.w, floatEquals(8.0));
+ }
+ });
+
+ test('test Float32x4List', () {
+ var counter;
+ final list = new Float32List(12);
+ for (int i = 0; i < list.length; ++i) {
+ list[i] = i * 1.0;
+ }
+ if (Platform.supportsSimd) {
+ counter = new Float32x4.zero();
+ final simdlist = new Float32x4List.view(list.buffer);
+ for (int i = 0; i < simdlist.length; ++i) {
+ counter += simdlist[i];
+ }
+ } else {
+ counter = new MyFloat32x4();
+ for (int i = 0; i < list.length; i += 4) {
+ counter.x += list[i];
+ counter.y += list[i+1];
+ counter.z += list[i+2];
+ counter.w += list[i+3];
+ }
+ }
+ expect(counter.x, floatEquals(12.0));
+ expect(counter.y, floatEquals(15.0));
+ expect(counter.z, floatEquals(18.0));
+ expect(counter.w, floatEquals(21.0));
+ });
+
+ test('test Int32x4', () {
+ if (Platform.supportsSimd) {
+ final val = new Int32x4(1, 2, 3, 4);
+ expect(val.x, equals(1));
+ expect(val.y, equals(2));
+ expect(val.z, equals(3));
+ expect(val.w, equals(4));
+ final val2 = val ^ val;
+ expect(val2.x, equals(0));
+ expect(val2.y, equals(0));
+ expect(val2.z, equals(0));
+ expect(val2.w, equals(0));
+ }
+ });
+}
« no previous file with comments | « test/codegen/lib/html/typed_arrays_range_checks_test.dart ('k') | test/codegen/lib/html/typing_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698