THRIFT-4382: Replace the use of Indirect Object Syntax calls to new()
diff --git a/test/perl/TestClient.pl b/test/perl/TestClient.pl
index 990274c..96e3bec 100755
--- a/test/perl/TestClient.pl
+++ b/test/perl/TestClient.pl
@@ -45,7 +45,7 @@
$|++;
sub usage {
- print <<EOF;
+ print <<"EOF";
Usage: $0 [OPTIONS]
Options: (default)
@@ -91,20 +91,24 @@
}
my $socket = undef;
-if ($opts{"domain-socket"}) {
- $socket = new Thrift::UnixSocket($opts{"domain-socket"});
-} elsif ($opts{ssl}) {
- $socket = new Thrift::SSLSocket(\%opts);
-} else {
- $socket = new Thrift::Socket($opts{host}, $opts{port});
+if ($opts{'domain-socket'}) {
+ $socket = Thrift::UnixSocket->new($opts{'domain-socket'});
+}
+elsif ($opts{ssl}) {
+ $socket = Thrift::SSLSocket->new(\%opts);
+}
+else {
+ $socket = Thrift::Socket->new($opts{host}, $opts{port});
}
my $transport;
if ($opts{transport} eq 'buffered') {
- $transport = new Thrift::BufferedTransport($socket, 1024, 1024);
-} elsif ($opts{transport} eq 'framed') {
- $transport = new Thrift::FramedTransport($socket);
-} else {
+ $transport = Thrift::BufferedTransport->new($socket, 1024, 1024);
+}
+elsif ($opts{transport} eq 'framed') {
+ $transport = Thrift::FramedTransport->new($socket);
+}
+else {
usage();
exit 1;
}
@@ -112,20 +116,21 @@
my $protocol;
my $protocol2;
if ($opts{protocol} eq 'binary' || $opts{protocol} eq 'multi') {
- $protocol = new Thrift::BinaryProtocol($transport);
-} else {
+ $protocol = Thrift::BinaryProtocol->new($transport);
+}
+else {
usage();
exit 1;
}
my $secondService = undef;
if (index($opts{protocol}, 'multi') == 0) {
- $protocol2 = new Thrift::MultiplexedProtocol($protocol, "SecondService");
- $protocol = new Thrift::MultiplexedProtocol($protocol, "ThriftTest");
- $secondService = new ThriftTest::SecondServiceClient($protocol2);
+ $protocol2 = Thrift::MultiplexedProtocol->new($protocol, 'SecondService');
+ $protocol = Thrift::MultiplexedProtocol->new($protocol, 'ThriftTest');
+ $secondService = ThriftTest::SecondServiceClient->new($protocol2);
}
-my $testClient = new ThriftTest::ThriftTestClient($protocol);
+my $testClient = ThriftTest::ThriftTestClient->new($protocol);
eval {
$transport->open();
@@ -146,52 +151,52 @@
#
# VOID TEST
#
-print("testVoid()");
+print('testVoid()');
$testClient->testVoid();
print(" = void\n");
#
# STRING TEST
#
-print("testString(\"Test\")");
-my $s = $testClient->testString("Test");
-print(" = \"$s\"\n");
+print('testString("Test")');
+my $s = $testClient->testString('Test');
+print(qq| = "$s"\n|);
exit(ERR_BASETYPES) if ($s ne 'Test');
#
# MULTIPLEXED TEST
#
if (index($opts{protocol}, 'multi') == 0) {
- print("secondtestString(\"Test2\")");
- $s = $secondService->secondtestString("Test2");
- print(" = \"$s\"\n");
+ print('secondtestString("Test2")');
+ $s = $secondService->secondtestString('Test2');
+ print(qq| = "$s"\n|);
exit(ERR_PROTOCOL) if ($s ne 'testString("Test2")');
}
#
# BOOL TEST
#
-print("testBool(1)");
+print('testBool(1)');
my $t = $testClient->testBool(1);
print(" = $t\n");
exit(ERR_BASETYPES) if ($t ne 1);
-print("testBool(0)");
+print('testBool(0)');
my $f = $testClient->testBool(0);
print(" = $f\n");
-exit(ERR_BASETYPES) if ($f ne "");
+exit(ERR_BASETYPES) if ($f ne q||);
#
# BYTE TEST
#
-print("testByte(1)");
+print('testByte(1)');
my $u8 = $testClient->testByte(1);
print(" = $u8\n");
#
# I32 TEST
#
-print("testI32(-1)");
+print('testI32(-1)');
my $i32 = $testClient->testI32(-1);
print(" = $i32\n");
exit(ERR_BASETYPES) if ($i32 ne -1);
@@ -199,7 +204,7 @@
#
# I64 TEST
#
-print("testI64(-34359738368)");
+print('testI64(-34359738368)');
my $i64 = $testClient->testI64(-34359738368);
print(" = $i64\n");
exit(ERR_BASETYPES) if ($i64 ne -34359738368);
@@ -207,7 +212,7 @@
#
# DOUBLE TEST
#
-print("testDouble(-852.234234234)");
+print('testDouble(-852.234234234)');
my $dub = $testClient->testDouble(-852.234234234);
print(" = $dub\n");
exit(ERR_BASETYPES) if ($dub ne -852.234234234);
@@ -220,33 +225,33 @@
#
# STRUCT TEST
#
-print("testStruct({\"Zero\", 1, -3, -5})");
-my $out = new ThriftTest::Xtruct();
-$out->string_thing("Zero");
+print('testStruct({"Zero", 1, -3, -5})');
+my $out = ThriftTest::Xtruct->new();
+$out->string_thing('Zero');
$out->byte_thing(1);
$out->i32_thing(-3);
$out->i64_thing(-5);
my $in = $testClient->testStruct($out);
-print(" = {\"".$in->string_thing."\", ".
- $in->byte_thing.", ".
- $in->i32_thing.", ".
+print(' = {"'.$in->string_thing.'", '.
+ $in->byte_thing.', '.
+ $in->i32_thing.', '.
$in->i64_thing."}\n");
#
# NESTED STRUCT TEST
#
-print("testNest({1, {\"Zero\", 1, -3, -5}, 5}");
-my $out2 = new ThriftTest::Xtruct2();
+print('testNest({1, {"Zero", 1, -3, -5}, 5}');
+my $out2 = ThriftTest::Xtruct2->new();
$out2->byte_thing(1);
$out2->struct_thing($out);
$out2->i32_thing(5);
my $in2 = $testClient->testNest($out2);
$in = $in2->struct_thing;
-print(" = {".$in2->byte_thing.", {\"".
- $in->string_thing."\", ".
- $in->byte_thing.", ".
- $in->i32_thing.", ".
- $in->i64_thing."}, ".
+print(' = {'.$in2->byte_thing.', {"'.
+ $in->string_thing.'", '.
+ $in->byte_thing.', '.
+ $in->i32_thing.', '.
+ $in->i64_thing.'}, '.
$in2->i32_thing."}\n");
#
@@ -256,28 +261,30 @@
for (my $i = 0; $i < 5; ++$i) {
$mapout->{$i} = $i-10;
}
-print("testMap({");
+print('testMap({');
my $first = 1;
while( my($key,$val) = each %$mapout) {
if ($first) {
$first = 0;
- } else {
- print(", ");
+ }
+ else {
+ print(', ');
}
print("$key => $val");
}
-print("})");
+print('})');
my $mapin = $testClient->testMap($mapout);
-print(" = {");
+print(' = {');
$first = 1;
while( my($key,$val) = each %$mapin){
if ($first) {
$first = 0;
- } else {
- print(", ");
+ }
+ else {
+ print(', ');
}
print("$key => $val");
}
@@ -291,11 +298,11 @@
push(@$setout, $i);
}
-print("testSet({".join(",",@$setout)."})");
+print('testSet({'.join(',',@$setout).'})');
my $setin = $testClient->testSet($setout);
-print(" = {".join(",",@$setout)."}\n");
+print(' = {'.join(',',@$setout)."}\n");
#
# LIST TEST
@@ -305,111 +312,111 @@
push(@$listout, $i);
}
-print("testList({".join(",",@$listout)."})");
+print('testList({'.join(',',@$listout).'})');
my $listin = $testClient->testList($listout);
-print(" = {".join(",",@$listin)."}\n");
+print(' = {'.join(',',@$listin)."}\n");
#
# ENUM TEST
#
-print("testEnum(ONE)");
+print('testEnum(ONE)');
my $ret = $testClient->testEnum(ThriftTest::Numberz::ONE);
print(" = $ret\n");
-print("testEnum(TWO)");
+print('testEnum(TWO)');
$ret = $testClient->testEnum(ThriftTest::Numberz::TWO);
print(" = $ret\n");
-print("testEnum(THREE)");
+print('testEnum(THREE)');
$ret = $testClient->testEnum(ThriftTest::Numberz::THREE);
print(" = $ret\n");
-print("testEnum(FIVE)");
+print('testEnum(FIVE)');
$ret = $testClient->testEnum(ThriftTest::Numberz::FIVE);
print(" = $ret\n");
-print("testEnum(EIGHT)");
+print('testEnum(EIGHT)');
$ret = $testClient->testEnum(ThriftTest::Numberz::EIGHT);
print(" = $ret\n");
#
# TYPEDEF TEST
#
-print("testTypedef(309858235082523)");
+print('testTypedef(309858235082523)');
my $uid = $testClient->testTypedef(309858235082523);
print(" = $uid\n");
#
# NESTED MAP TEST
#
-print("testMapMap(1)");
+print('testMapMap(1)');
my $mm = $testClient->testMapMap(1);
-print(" = {");
+print(' = {');
while( my ($key,$val) = each %$mm) {
print("$key => {");
while( my($k2,$v2) = each %$val) {
print("$k2 => $v2, ");
}
- print("}, ");
+ print('}, ');
}
print("}\n");
#
# INSANITY TEST
#
-my $insane = new ThriftTest::Insanity();
+my $insane = ThriftTest::Insanity->new();
$insane->{userMap}->{ThriftTest::Numberz::FIVE} = 5000;
-my $truck = new ThriftTest::Xtruct();
-$truck->string_thing("Hello2");
+my $truck = ThriftTest::Xtruct->new();
+$truck->string_thing('Hello2');
$truck->byte_thing(2);
$truck->i32_thing(2);
$truck->i64_thing(2);
-my $truck2 = new ThriftTest::Xtruct();
-$truck2->string_thing("Goodbye4");
+my $truck2 = ThriftTest::Xtruct->new();
+$truck2->string_thing('Goodbye4');
$truck2->byte_thing(4);
$truck2->i32_thing(4);
$truck2->i64_thing(4);
push(@{$insane->{xtructs}}, $truck);
push(@{$insane->{xtructs}}, $truck2);
-print("testInsanity()");
+print('testInsanity()');
my $whoa = $testClient->testInsanity($insane);
-print(" = {");
+print(' = {');
while( my ($key,$val) = each %$whoa) {
print("$key => {");
while( my($k2,$v2) = each %$val) {
print("$k2 => {");
my $userMap = $v2->{userMap};
- print("{");
- if (ref($userMap) eq "HASH") {
+ print('{');
+ if (ref($userMap) eq 'HASH') {
while( my($k3,$v3) = each %$userMap) {
print("$k3 => $v3, ");
}
}
- print("}, ");
+ print('}, ');
my $xtructs = $v2->{xtructs};
- print("{");
- if (ref($xtructs) eq "ARRAY") {
+ print('{');
+ if (ref($xtructs) eq 'ARRAY') {
foreach my $x (@$xtructs) {
- print("{\"".$x->{string_thing}."\", ".
- $x->{byte_thing}.", ".$x->{i32_thing}.", ".$x->{i64_thing}."}, ");
+ print('{"'.$x->{string_thing}.'", '.
+ $x->{byte_thing}.', '.$x->{i32_thing}.', '.$x->{i64_thing}.'}, ');
}
}
- print("}");
+ print('}');
- print("}, ");
+ print('}, ');
}
- print("}, ");
+ print('}, ');
}
print("}\n");
#
# EXCEPTION TEST
#
-print("testException('Xception')");
+print(q|testException('Xception')|);
eval {
$testClient->testException('Xception');
print(" void\nFAILURE\n");
@@ -422,7 +429,7 @@
# Normal tests done.
#
my $stop = gettimeofday();
-my $elp = sprintf("%d",1000*($stop - $start), 0);
+my $elp = sprintf('%d',1000*($stop - $start), 0);
print("Total time: $elp ms\n");
#