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

Side by Side Diff: third_party/grpc/src/php/tests/generated_code/math_client.php

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
(Empty)
1 <?php
2 /*
3 *
4 * Copyright 2015, Google Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following disclaimer
15 * in the documentation and/or other materials provided with the
16 * distribution.
17 * * Neither the name of Google Inc. nor the names of its
18 * contributors may be used to endorse or promote products derived from
19 * this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 */
34
35 # Fix the following two lines to point to your installation
36 include 'vendor/autoload.php';
37 include 'tests/generated_code/math.php';
38
39 function p($line)
40 {
41 print("$line<br/>\n");
42 }
43
44 $host = 'localhost:50051';
45 p("Connecting to host: $host");
46 $client = new math\MathClient($host, []);
47 p('Client class: '.get_class($client));
48 p('');
49
50 p('Running unary call test:');
51 $dividend = 7;
52 $divisor = 4;
53 $div_arg = new math\DivArgs();
54 $div_arg->setDividend($dividend);
55 $div_arg->setDivisor($divisor);
56 $call = $client->Div($div_arg);
57 p('Call peer: '.$call->getPeer());
58 p("Dividing $dividend by $divisor");
59 list($response, $status) = $call->wait();
60 p('quotient = '.$response->getQuotient());
61 p('remainder = '.$response->getRemainder());
62 p('');
63
64 p('Running server streaming test:');
65 $limit = 7;
66 $fib_arg = new math\FibArgs();
67 $fib_arg->setLimit($limit);
68 $call = $client->Fib($fib_arg);
69 $result_array = iterator_to_array($call->responses());
70 $result = '';
71 foreach ($result_array as $num) {
72 $result .= ' '.$num->getNum();
73 }
74 p("The first $limit Fibonacci numbers are:".$result);
75 p('');
76
77 p('Running client streaming test:');
78 $call = $client->Sum();
79 for ($i = 0; $i <= $limit; ++$i) {
80 $num = new math\Num();
81 $num->setNum($i);
82 $call->write($num);
83 }
84 list($response, $status) = $call->wait();
85 p(sprintf('The first %d positive integers sum to: %d',
86 $limit, $response->getNum()));
87 p('');
88
89 p('Running bidi-streaming test:');
90 $call = $client->DivMany();
91 for ($i = 0; $i < 7; ++$i) {
92 $div_arg = new math\DivArgs();
93 $dividend = 2 * $i + 1;
94 $divisor = 3;
95 $div_arg->setDividend($dividend);
96 $div_arg->setDivisor($divisor);
97 $call->write($div_arg);
98 p("client writing: $dividend / $divisor");
99 $response = $call->read();
100 p(sprintf('server writing: quotient = %d, remainder = %d',
101 $response->getQuotient(), $response->getRemainder()));
102 }
103 $call->writesDone();
OLDNEW
« no previous file with comments | « third_party/grpc/src/php/tests/generated_code/math.proto ('k') | third_party/grpc/src/php/tests/interop/empty.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698