anchor.diff:      results = parser.parse(args);
     } catch (e) {
       stdout.writeln('$e\n');
  -    results = null;
  -  }
  -
  -  if (results == null) {
  -    print(parser.usage);
  -    exit(0);
  -  }
  -
  -  verbose = results['verbose'] == true;
  -
  -  await init(
  -      host: results['host'],
  -      port: int.parse(results['port']),
  -      transportType: results['transport'],
  -      protocolType: results['protocol']).then((_) {
  -    exit(0);
  -  }).catchError((e) {
  -    stdout.writeln('Error:');
  -    stdout.writeln('$e');
  -    if (e is Error) {
  -      stdout.writeln('${e.stackTrace}');
  -    }
  -    exit(1);
  -  });
  -  exit(0);
  +  }
  +
  +  if (results == null) stdout.write(parser.usage);
  +
  +  return results;
   }
   
   TProtocolFactory getProtocolFactory(String protocolType) {
  
positive.code: 
      var result = await client.testMulti(input.byte_thing, input.i32_thing,
          input.i64_thing, {1: 'one'}, Numberz.EIGHT, 5678);
      if ('$result' != '$input') throw new StateError('$result != $input');
    });
  
    await _test('testException', () async {
      try {
        await client.testException('Xception');
      } on Xception catch (x) {
        return;
      }
  
      throw new StateError('expected an Xception');
    });
  
    await _test('testMultiException', () async {
      try {
        await client.testMultiException('Xception2', 'foo');
      } on Xception2 catch (x) {
        return;
      }
  
      throw new StateError('expected an Xception2');
    });
  }
  
  Future _testEnum(int input) async {
    var result = await client.testEnum(input);
    if (result != input) throw new StateError('$result != $input');
  }
  
negative.code: import 'package:thrift/thrift_console.dart';
  import 'package:thrift_test/thrift_test.dart';
  
  const TEST_BASETYPES = 1; // 0000 0001
  const TEST_STRUCTS = 2; // 0000 0010
  const TEST_CONTAINERS = 4; // 0000 0100
  const TEST_EXCEPTIONS = 8; // 0000 1000
  const TEST_UNKNOWN = 64; // 0100 0000 (Failed to prepare environemt etc.)
  const TEST_TIMEOUT = 128; // 1000 0000
  const TEST_NOTUSED = 48; // 0011 0000 (reserved bits)
  
  typedef Future FutureFunction();
  
  class TTest {
    final int errorCode;
    final String name;
    final FutureFunction func;
  
    TTest(this.errorCode, this.name, this.func);
  }
  
  class TTestError extends Error {
    final actual;
    final expected;
  
    TTestError(this.actual, this.expected);
  
    String toString() => '$actual != $expected';
  }
  
  List<TTest> _tests;
  ThriftTestClient client;
  bool verbose;
  
  /// Adapted from TestClient.php
  main(List<String> args) async {
    ArgResults results = _parseArgs(args);
  
    if (results == null) {
      exit(TEST_UNKNOWN);
    }
  
    verbose = results['verbose'] == true;
  
    await _initTestClient(
        host: results['host'],
        port: int.parse(results['port']),
        transportType: results['transport'],
        protocolType: results['protocol']).catchError((e) {
      stdout.writeln('Error:');
      stdout.writeln('$e');
      if (e is Error) {
        stdout.writeln('${e.stackTrace}');
      }
      exit(TEST_UNKNOWN);
    });
  
    // run tests
    _tests = _createTests();
  
    int result = 0;
  
    for (TTest test in _tests) {
      if (verbose) stdout.write('${test.name}... ');
      try {
        await test.func();
        if (verbose) stdout.writeln('success!');
      } catch (e) {
        if (verbose) stdout.writeln('$e');
        result = result | test.errorCode;
      }
    }
  
    exit(result);
  }
  
  ArgResults _parseArgs(List<String> args) {
    var parser = new ArgParser();
    parser.addOption('host', defaultsTo: 'localhost', help: 'The server host');
    parser.addOption('port', defaultsTo: '9090', help: 'The port to connect to');
  