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

Side by Side Diff: tests/standalone/io/process_stdout_test.dart

Issue 10829459: Deprecate Math object in corelib in favor of dart:math library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 // 4 //
5 // Process test program to test process communication. 5 // Process test program to test process communication.
6 // 6 //
7 // VMOptions= 7 // VMOptions=
8 // VMOptions=--short_socket_read 8 // VMOptions=--short_socket_read
9 // VMOptions=--short_socket_write 9 // VMOptions=--short_socket_write
10 // VMOptions=--short_socket_read --short_socket_write 10 // VMOptions=--short_socket_read --short_socket_write
11 11
12 #import("dart:io"); 12 #import("dart:io");
13 #import("dart:math");
14
13 #source("process_test_util.dart"); 15 #source("process_test_util.dart");
14 16
15 void test(Process process, int expectedExitCode) { 17 void test(Process process, int expectedExitCode) {
16 // Wait for the process to start and then interact with it. 18 // Wait for the process to start and then interact with it.
17 process.onStart = () { 19 process.onStart = () {
18 List<int> data = "ABCDEFGHI\n".charCodes(); 20 List<int> data = "ABCDEFGHI\n".charCodes();
19 final int dataSize = data.length; 21 final int dataSize = data.length;
20 22
21 InputStream input = process.stdout; 23 InputStream input = process.stdout;
22 OutputStream output = process.stdin; 24 OutputStream output = process.stdin;
23 25
24 int received = 0; 26 int received = 0;
25 List<int> buffer = []; 27 List<int> buffer = [];
26 28
27 void readData() { 29 void readData() {
28 buffer.addAll(input.read()); 30 buffer.addAll(input.read());
29 for (int i = received; 31 for (int i = received;
30 i < Math.min(data.length, buffer.length) - 1; 32 i < min(data.length, buffer.length) - 1;
31 i++) { 33 i++) {
32 Expect.equals(data[i], buffer[i]); 34 Expect.equals(data[i], buffer[i]);
33 } 35 }
34 received = buffer.length; 36 received = buffer.length;
35 if (received >= dataSize) { 37 if (received >= dataSize) {
36 // We expect an extra character on windows due to carriage return. 38 // We expect an extra character on windows due to carriage return.
37 if (13 === buffer[dataSize - 1] && dataSize + 1 === received) { 39 if (13 === buffer[dataSize - 1] && dataSize + 1 === received) {
38 Expect.equals(13, buffer[dataSize - 1]); 40 Expect.equals(13, buffer[dataSize - 1]);
39 Expect.equals(10, buffer[dataSize]); 41 Expect.equals(10, buffer[dataSize]);
40 buffer.removeLast(); 42 buffer.removeLast();
(...skipping 21 matching lines...) Expand all
62 64
63 // Run the test using the dart binary with an echo script. 65 // Run the test using the dart binary with an echo script.
64 // The test runner can be run from either the root or from runtime. 66 // The test runner can be run from either the root or from runtime.
65 var scriptFile = new File("tests/standalone/io/process_std_io_script.dart"); 67 var scriptFile = new File("tests/standalone/io/process_std_io_script.dart");
66 if (!scriptFile.existsSync()) { 68 if (!scriptFile.existsSync()) {
67 scriptFile = new File("../tests/standalone/io/process_std_io_script.dart"); 69 scriptFile = new File("../tests/standalone/io/process_std_io_script.dart");
68 } 70 }
69 Expect.isTrue(scriptFile.existsSync()); 71 Expect.isTrue(scriptFile.existsSync());
70 test(Process.start(new Options().executable, [scriptFile.name, "0"]), 0); 72 test(Process.start(new Options().executable, [scriptFile.name, "0"]), 0);
71 } 73 }
OLDNEW
« no previous file with comments | « tests/standalone/io/process_stderr_test.dart ('k') | tests/standalone/io/web_socket_protocol_processor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698