OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 // VMOptions=--deoptimization_counter_threshold=1000 --optimization-counter-thre
shold=10 | |
5 | |
6 // Library tag to be able to run in html test framework. | |
7 library uint32x4_arithmetic_test; | |
8 | |
9 import "package:expect/expect.dart"; | |
10 import 'dart:typed_data'; | |
11 | |
12 testAdd() { | |
13 var m = new Uint32x4(0, 0, 0, 0); | |
14 var n = new Uint32x4(-1, -1, -1, -1); | |
15 var o = m + n; | |
16 Expect.equals(4294967295, o.x); | |
17 Expect.equals(4294967295, o.y); | |
18 Expect.equals(4294967295, o.z); | |
19 Expect.equals(4294967295, o.w); | |
20 | |
21 m = new Uint32x4(0, 0, 0, 0); | |
22 n = new Uint32x4(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); | |
23 o = m + n; | |
24 Expect.equals(4294967295, o.x); | |
25 Expect.equals(4294967295, o.y); | |
26 Expect.equals(4294967295, o.z); | |
27 Expect.equals(4294967295, o.w); | |
28 | |
29 n = new Uint32x4(1, 1, 1, 1); | |
30 m = new Uint32x4(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); | |
31 o = m + n; | |
32 Expect.equals(0, o.x); | |
33 Expect.equals(0, o.y); | |
34 Expect.equals(0, o.z); | |
35 Expect.equals(0, o.w); | |
36 | |
37 n = new Uint32x4(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); | |
38 m = new Uint32x4(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); | |
39 o = m + n; | |
40 Expect.equals(4294967294, o.x); | |
41 Expect.equals(4294967294, o.y); | |
42 Expect.equals(4294967294, o.z); | |
43 Expect.equals(4294967294, o.w); | |
44 | |
45 n = new Uint32x4(1, 0, 0, 0); | |
46 m = new Uint32x4(2, 0, 0, 0); | |
47 o = n + m; | |
48 Expect.equals(3, o.x); | |
49 Expect.equals(0, o.y); | |
50 Expect.equals(0, o.z); | |
51 Expect.equals(0, o.w); | |
52 | |
53 n = new Uint32x4(1, 3, 0, 0); | |
54 m = new Uint32x4(2, 4, 0, 0); | |
55 o = n + m; | |
56 Expect.equals(3, o.x); | |
57 Expect.equals(7, o.y); | |
58 Expect.equals(0, o.z); | |
59 Expect.equals(0, o.w); | |
60 | |
61 n = new Uint32x4(1, 3, 5, 0); | |
62 m = new Uint32x4(2, 4, 6, 0); | |
63 o = n + m; | |
64 Expect.equals(3, o.x); | |
65 Expect.equals(7, o.y); | |
66 Expect.equals(11, o.z); | |
67 Expect.equals(0, o.w); | |
68 | |
69 n = new Uint32x4(1, 3, 5, 7); | |
70 m = new Uint32x4(2, 4, 6, 8); | |
71 o = n + m; | |
72 Expect.equals(3, o.x); | |
73 Expect.equals(7, o.y); | |
74 Expect.equals(11, o.z); | |
75 Expect.equals(15, o.w); | |
76 } | |
77 | |
78 testSub() { | |
79 var m = new Uint32x4(0, 0, 0, 0); | |
80 var n = new Uint32x4(1, 1, 1, 1); | |
81 var o = m - n; | |
82 Expect.equals(4294967295, o.x); | |
83 Expect.equals(4294967295, o.y); | |
84 Expect.equals(4294967295, o.z); | |
85 Expect.equals(4294967295, o.w); | |
86 | |
87 o = n - m; | |
88 Expect.equals(1, o.x); | |
89 Expect.equals(1, o.y); | |
90 Expect.equals(1, o.z); | |
91 Expect.equals(1, o.w); | |
92 } | |
93 | |
94 main() { | |
95 for (int i = 0; i < 20; i++) { | |
96 testAdd(); | |
97 testSub(); | |
98 } | |
99 } | |
OLD | NEW |