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

Unified Diff: tests/service_tests/conformance/java/ConformanceTest.java

Issue 2035023003: Remove service-compiler related code. (Closed) Base URL: git@github.com:dartino/sdk.git@master
Patch Set: Created 4 years, 6 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
Index: tests/service_tests/conformance/java/ConformanceTest.java
diff --git a/tests/service_tests/conformance/java/ConformanceTest.java b/tests/service_tests/conformance/java/ConformanceTest.java
deleted file mode 100644
index 4a6104b7f71b0127683d90606a0673084ccc6c25..0000000000000000000000000000000000000000
--- a/tests/service_tests/conformance/java/ConformanceTest.java
+++ /dev/null
@@ -1,318 +0,0 @@
-// Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE.md file.
-
-import dartino.*;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-import java.util.List;
-
-class ConformanceTest {
- public static void main(String args[]) {
- // Expecting a snapshot of the dart service code on the command line.
- if (args.length != 1) {
- System.out.println("Usage: java ConformanceTest <snapshot>");
- System.out.println(" or: java ConformanceTest <port>");
- System.exit(1);
- }
-
- // Load libdartino.so.
- System.loadLibrary("dartino");
-
- // Setup Dartino.
- DartinoApi.Setup();
- DartinoServiceApi.Setup();
- DartinoApi.AddDefaultSharedLibrary("libdartino.so");
-
- int port = 0;
- try {
- port = Integer.parseInt(args[0]);
- } catch (NumberFormatException e) {
- // Since the argument is not a number we expect it to be the snapshot.
- }
-
- if (port > 0) {
- System.out.println(
- "Waiting for debugger connection on localhost:" + port);
- Thread dartThread = new Thread(new DebugRunner(port));
- dartThread.start();
- } else {
- try {
- // Load snapshot and start Dart code on a separate thread.
- FileInputStream snapshotStream = new FileInputStream(args[0]);
- int available = snapshotStream.available();
- byte[] snapshot = new byte[available];
- snapshotStream.read(snapshot);
- Thread dartThread = new Thread(new SnapshotRunner(snapshot));
- dartThread.start();
- } catch (FileNotFoundException e) {
- System.err.println("Failed loading snapshot");
- System.exit(1);
- } catch (IOException e) {
- System.err.println("Failed loading snapshot");
- System.exit(1);
- }
- }
-
- // Run conformance tests.
- ConformanceService.Setup();
- try {
- runPersonTests();
- runPersonBoxTests();
- runNodeTests();
- } finally {
- ConformanceService.TearDown();
- }
- }
-
- private static void buildPerson(PersonBuilder person, int n) {
- person.setAge(n * 20);
- if (n > 1) {
- PersonListBuilder children = person.initChildren(2);
- buildPerson(children.get(0), n - 1);
- buildPerson(children.get(1), n - 1);
- }
- }
-
- private static void runPersonTests() {
- {
- MessageBuilder builder = new MessageBuilder(512);
- PersonBuilder person = new PersonBuilder();
- builder.initRoot(person, PersonBuilder.kSize);
- buildPerson(person, 7);
- assert 3144 == builder.computeUsed();
- int age = ConformanceService.getAge(person);
- assert 140 == age;
- }
-
- {
- MessageBuilder builder = new MessageBuilder(512);
- PersonBuilder person = new PersonBuilder();
- builder.initRoot(person, PersonBuilder.kSize);
- buildPerson(person, 7);
- assert 3144 == builder.computeUsed();
- ConformanceService.getAgeAsync(
- person,
- new ConformanceService.GetAgeCallback() {
- public void handle(int age) {
- assert 140 == age;
- }
- });
- }
-
- {
- MessageBuilder builder = new MessageBuilder(512);
- PersonBuilder person = new PersonBuilder();
- builder.initRoot(person, PersonBuilder.kSize);
- buildPerson(person, 7);
- assert 3144 == builder.computeUsed();
- int count = ConformanceService.count(person);
- assert 127 == count;
- }
-
- {
- MessageBuilder builder = new MessageBuilder(512);
- PersonBuilder person = new PersonBuilder();
- builder.initRoot(person, PersonBuilder.kSize);
- buildPerson(person, 7);
- assert 3144 == builder.computeUsed();
- ConformanceService.countAsync(
- person,
- new ConformanceService.CountCallback() {
- public void handle(int count) {
- assert 127 == count;
- }
- });
- }
-
- {
- MessageBuilder builder = new MessageBuilder(512);
- PersonBuilder person = new PersonBuilder();
- builder.initRoot(person, PersonBuilder.kSize);
- buildPerson(person, 7);
- assert 3144 == builder.computeUsed();
- AgeStats stats = ConformanceService.getAgeStats(person);
- assert 39 == stats.getAverageAge();
- assert 4940 == stats.getSum();
- }
-
- {
- MessageBuilder builder = new MessageBuilder(512);
- PersonBuilder person = new PersonBuilder();
- builder.initRoot(person, PersonBuilder.kSize);
- buildPerson(person, 7);
- assert 3144 == builder.computeUsed();
- ConformanceService.getAgeStatsAsync(
- person,
- new ConformanceService.GetAgeStatsCallback() {
- public void handle(AgeStats stats) {
- assert 39 == stats.getAverageAge();
- assert 4940 == stats.getSum();
- }
- });
- }
-
- {
- AgeStats stats = ConformanceService.createAgeStats(42, 42);
- assert 42 == stats.getAverageAge();
- assert 42 == stats.getSum();
- }
-
- {
- ConformanceService.createAgeStatsAsync(
- 42, 42,
- new ConformanceService.CreateAgeStatsCallback() {
- public void handle(AgeStats stats) {
- assert 42 == stats.getAverageAge();
- assert 42 == stats.getSum();
- }
- });
- }
-
- {
- Person generated = ConformanceService.createPerson(10);
- assert 42 == generated.getAge();
- String name = generated.getName();
- assert 6 == name.length();
- assert name.equals("person");
- Uint16List nameData = generated.getNameData();
- assert 6 == nameData.size();
- assert "p".charAt(0) == nameData.get(0);
- assert "n".charAt(0) == nameData.get(5);
- PersonList children = generated.getChildren();
- assert 10 == children.size();
- for (int i = 0; i < children.size(); i++) {
- assert (12 + i * 2) == children.get(i).getAge();
- }
- }
-
- {
- ConformanceService.createPersonAsync(
- 10,
- new ConformanceService.CreatePersonCallback() {
- public void handle(Person generated) {
- assert 42 == generated.getAge();
- String name = generated.getName();
- assert 6 == name.length();
- assert name.equals("person");
- Uint16List nameData = generated.getNameData();
- assert 6 == nameData.size();
- assert "p".charAt(0) == nameData.get(0);
- assert "n".charAt(0) == nameData.get(5);
- PersonList children = generated.getChildren();
- assert 10 == children.size();
- for (int i = 0; i < children.size(); i++) {
- assert (12 + i * 2) == children.get(i).getAge();
- }
- }
- });
- }
-
- ConformanceService.foo();
- ConformanceService.fooAsync(new ConformanceService.FooCallback() {
- final int data = 101;
- public void handle() {
- assert 101 == data;
- }
- });
-
- {
- MessageBuilder builder = new MessageBuilder(512);
- EmptyBuilder empty = new EmptyBuilder();
- builder.initRoot(empty, EmptyBuilder.kSize);
- int i = ConformanceService.bar(empty);
- assert 24 == i;
- }
-
- {
- MessageBuilder builder = new MessageBuilder(512);
- EmptyBuilder empty = new EmptyBuilder();
- builder.initRoot(empty, EmptyBuilder.kSize);
- ConformanceService.barAsync(empty, new ConformanceService.BarCallback() {
- final int data = 102;
- public void handle(int i) {
- assert 102 == data;
- assert 24 == i;
- }
- });
- }
-
- assert 42 == ConformanceService.ping();
- ConformanceService.pingAsync(new ConformanceService.PingCallback() {
- public void handle(int result) { assert 42 == result; }
- });
-
- {
- MessageBuilder builder = new MessageBuilder(512);
- TableFlipBuilder flip = new TableFlipBuilder();
- builder.initRoot(flip, TableFlipBuilder.kSize);
- String expectedFlip = "(╯°□°)╯︵ ┻━┻";
- flip.setFlip(expectedFlip);
- TableFlip flipResult = ConformanceService.flipTable(flip);
- assert flipResult.getFlip().equals(expectedFlip);
- }
-
- {
- MessageBuilder builder = new MessageBuilder(512);
- TableFlipBuilder flip = new TableFlipBuilder();
- builder.initRoot(flip, TableFlipBuilder.kSize);
- final String expectedFlip = "(╯°□°)╯︵ ┻━┻";
- flip.setFlip(expectedFlip);
- ConformanceService.flipTableAsync(
- flip,
- new ConformanceService.FlipTableCallback() {
- public void handle(TableFlip flipResult) {
- assert flipResult.getFlip().equals(expectedFlip);
- };
- });
- }
- }
-
- private static void runPersonBoxTests() {
- MessageBuilder builder = new MessageBuilder(512);
-
- PersonBoxBuilder box = new PersonBoxBuilder();
- builder.initRoot(box, PersonBoxBuilder.kSize);
- PersonBuilder person = box.initPerson();
- person.setAge(87);
- person.setName("fisk");
- int age = ConformanceService.getBoxedAge(box);
- assert 87 == age;
- }
-
-
- private static int depth(Node node) {
- if (node.isNum()) return 1;
- int left = depth(node.getCons().getFst());
- int right = depth(node.getCons().getSnd());
- return 1 + ((left > right) ? left : right);
- }
-
- private static void buildNode(NodeBuilder node, int n) {
- if (n > 1) {
- ConsBuilder cons = node.initCons();
- buildNode(cons.initFst(), n - 1);
- buildNode(cons.initSnd(), n - 1);
- } else {
- node.setCond(true);
- node.setNum(42);
- }
- }
-
- private static void runNodeTests() {
- MessageBuilder builder = new MessageBuilder(512);
-
- NodeBuilder root = new NodeBuilder();
- builder.initRoot(root, NodeBuilder.kSize);
- buildNode(root, 10);
- int depth = ConformanceService.depth(root);
- assert 10 == depth;
-
- Node node = ConformanceService.createNode(10);
- assert 24680 == node.computeUsed();
- assert 10 == depth(node);
- }
-}
« no previous file with comments | « tests/service_tests/conformance/conformance_test_shared.cc ('k') | tests/service_tests/conformance/java/DebugRunner.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698