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

Unified Diff: standalone/typed_array_test.dart

Issue 11341012: Added some new tests for issue 6311 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/tests/
Patch Set: Created 8 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: standalone/typed_array_test.dart
===================================================================
--- standalone/typed_array_test.dart (revision 0)
+++ standalone/typed_array_test.dart (revision 0)
@@ -0,0 +1,235 @@
+import 'dart:isolate';
+import 'dart:scalarlist';
+
+void main() {
+ int8_receiver();
+ uint8_receiver();
+ int16_receiver();
+ uint16_receiver();
+ int32_receiver();
+ uint32_receiver();
+ int64_receiver();
+ uint64_receiver();
+ float32_receiver();
+ float64_receiver();
+}
+
+// Int8 array.
+const int8_1 = 10;
+const int8_2 = 100;
+
+void int8_receiver() {
+ var sp = spawnFunction(int8_sender);
+ sp.call("hi").then((a) {
+ Expect.equals(int8_1, a[0]);
+ Expect.equals(int8_2, a[1]);
+ print("int8_receiver");
+ });
+}
+
+int8_sender() {
+ port.receive((m, r) {
Ivan Posva 2012/10/29 18:27:45 m is not being used below, maybe it should be on o
siva 2012/10/29 20:04:03 As discussed offline replaced "hi" with length of
+ var a = new Int8List(2);
+ a[0] = int8_1;
+ a[1] = int8_2;
+ r.send(a);
+ });
+}
+
+// Uint8 array.
+const uint8_1 = 0xff;
+const uint8_2 = 0x7f;
+
+void uint8_receiver() {
+ var sp = spawnFunction(uint8_sender);
+ sp.call("hi").then((a) {
+ Expect.equals(uint8_1, a[0]);
+ Expect.equals(uint8_2, a[1]);
+ print("uint8_receiver");
+ });
+}
+
+uint8_sender() {
+ port.receive((m, r) {
+ var a = new Uint8List(2);
+ a[0] = uint8_1;
+ a[1] = uint8_2;
+ r.send(a);
+ });
+}
+
+// Int16 array.
+const int16_1 = 1000;
+const int16_2 = 10000;
+
+void int16_receiver() {
+ var sp = spawnFunction(int16_sender);
+ sp.call("hi").then((a) {
+ Expect.equals(int16_1, a[0]);
+ Expect.equals(int16_2, a[1]);
+ print("int16_receiver");
+ });
+}
+
+int16_sender() {
+ port.receive((m, r) {
+ var a = new Int16List(2);
+ a[0] = int16_1;
+ a[1] = int16_2;
+ r.send(a);
+ });
+}
+
+// Uint16 array.
+const uint16_1 = 0xffff;
+const uint16_2 = 0x7fff;
+
+void uint16_receiver() {
+ var sp = spawnFunction(uint16_sender);
+ sp.call("hi").then((a) {
+ Expect.equals(uint16_1, a[0]);
+ Expect.equals(uint16_2, a[1]);
+ print("uint16_receiver");
+ });
+}
+
+uint16_sender() {
+ port.receive((m, r) {
+ var a = new Uint16List(2);
+ a[0] = uint16_1;
+ a[1] = uint16_2;
+ r.send(a);
+ });
+}
+
+// Int32 array.
+const int32_1 = 100000;
+const int32_2 = 1000000;
+
+void int32_receiver() {
+ var sp = spawnFunction(int32_sender);
+ sp.call("hi").then((a) {
+ Expect.equals(int32_1, a[0]);
+ Expect.equals(int32_2, a[1]);
+ print("int32_receiver");
+ });
+}
+
+int32_sender() {
+ port.receive((m, r) {
+ var a = new Int32List(2);
+ a[0] = int32_1;
+ a[1] = int32_2;
+ r.send(a);
+ });
+}
+
+// Uint32 array.
+const uint32_1 = 0xffffffff;
+const uint32_2 = 0x7fffffff;
+
+void uint32_receiver() {
+ var sp = spawnFunction(uint32_sender);
+ sp.call("hi").then((a) {
+ Expect.equals(uint32_1, a[0]);
+ Expect.equals(uint32_2, a[1]);
+ print("uint32_receiver");
+ });
+}
+
+uint32_sender() {
+ port.receive((m, r) {
+ var a = new Uint32List(2);
+ a[0] = uint32_1;
+ a[1] = uint32_2;
+ r.send(a);
+ });
+}
+
+// Int64 array.
+const int64_1 = 10000000;
+const int64_2 = 100000000;
+
+void int64_receiver() {
+ var sp = spawnFunction(int64_sender);
+ sp.call("hi").then((a) {
+ Expect.equals(int64_1, a[0]);
+ Expect.equals(int64_2, a[1]);
+ print("int64_receiver");
+ });
+}
+
+int64_sender() {
+ port.receive((m, r) {
+ var a = new Int64List(2);
+ a[0] = int64_1;
+ a[1] = int64_2;
+ r.send(a);
+ });
+}
+
+// Uint64 array.
+const uint64_1 = 0xffffffffffffffff;
+const uint64_2 = 0x7fffffffffffffff;
+
+void uint64_receiver() {
+ var sp = spawnFunction(uint64_sender);
+ sp.call("hi").then((a) {
+ Expect.equals(uint64_1, a[0]);
+ Expect.equals(uint64_2, a[1]);
+ print("uint64_receiver");
+ });
+}
+
+uint64_sender() {
+ port.receive((m, r) {
+ var a = new Uint64List(2);
+ a[0] = uint64_1;
+ a[1] = uint64_2;
+ r.send(a);
+ });
+}
+
+// Float32 Array.
+const float32_1 = 1.0;
+const float32_2 = 2.0;
+
+void float32_receiver() {
+ var sp = spawnFunction(float32_sender);
+ sp.call("hi").then((a) {
+ Expect.equals(float32_1, a[0]);
+ Expect.equals(float32_2, a[1]);
+ print("float32_receiver");
+ });
+}
+
+float32_sender() {
+ port.receive((m, r) {
+ var a = new Float32List(2);
+ a[0] = float32_1;
+ a[1] = float32_2;
+ r.send(a);
+ });
+}
+
+// Float64 Array.
+const float64_1 = 101.234;
+const float64_2 = 201.765;
+
+void float64_receiver() {
+ var sp = spawnFunction(float64_sender);
+ sp.call("hi").then((a) {
+ Expect.equals(float64_1, a[0]);
+ Expect.equals(float64_2, a[1]);
+ print("float64_receiver");
+ });
+}
+
+float64_sender() {
+ port.receive((m, r) {
+ var a = new Float64List(2);
+ a[0] = float64_1;
+ a[1] = float64_2;
+ r.send(a);
+ });
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698