This commit is contained in:
Mark Probst 2020-12-26 18:52:20 -05:00
Родитель 27d8581f18
Коммит 0c94006f4f
3 изменённых файлов: 44 добавлений и 11 удалений

Просмотреть файл

@ -124,7 +124,7 @@ function timeEnd(message: string, suffix: string): void {
export abstract class Fixture {
abstract name: string;
constructor(public language: languages.Language) { }
constructor(public language: languages.Language) {}
runForName(name: string): boolean {
return this.name === name;
@ -809,6 +809,7 @@ export const allFixtures: Fixture[] = [
new JSONFixture(languages.DartLanguage),
new JSONFixture(languages.PikeLanguage),
new JSONFixture(languages.HaskellLanguage),
new JSONFixture(languages.PHPLanguage),
new JSONSchemaJSONFixture(languages.CSharpLanguage),
new JSONTypeScriptFixture(languages.CSharpLanguage),
// new JSONSchemaFixture(languages.CrystalLanguage),
@ -831,6 +832,7 @@ export const allFixtures: Fixture[] = [
new JSONSchemaFixture(languages.DartLanguage),
new JSONSchemaFixture(languages.PikeLanguage),
new JSONSchemaFixture(languages.HaskellLanguage),
new JSONSchemaFixture(languages.PHPLanguage),
// FIXME: Why are we missing so many language with GraphQL?
new GraphQLFixture(languages.CSharpLanguage),
new GraphQLFixture(languages.JavaLanguage),
@ -847,5 +849,6 @@ export const allFixtures: Fixture[] = [
new GraphQLFixture(languages.DartLanguage),
new GraphQLFixture(languages.PikeLanguage),
new GraphQLFixture(languages.HaskellLanguage),
new GraphQLFixture(languages.PHPLanguage),
new CommandSuccessfulLanguageFixture(languages.JavaScriptPropTypesLanguage),
];

14
test/fixtures/php/main.php поставляемый Normal file
Просмотреть файл

@ -0,0 +1,14 @@
#!/usr/bin/php
<?php
require_once("./TopLevel.php");
$json_string_in = file_get_contents($argv[1]);
$json_in = json_decode($json_string_in);
$data = TopLevel::from($json_in);
$json_out = $data->to();
$json_string_out = json_encode($json_out);
echo($json_string_out);
?>

Просмотреть файл

@ -90,11 +90,7 @@ export const JavaLanguage: Language = {
diffViaSchema: false,
skipDiffViaSchema: [],
allowMissingNull: false,
features: [
"enum",
"union",
"uuid"
],
features: ["enum", "union", "uuid"],
output: "src/main/java/io/quicktype/TopLevel.java",
topLevel: "TopLevel",
skipJSON: ["identifiers.json", "simple-identifiers.json", "nst-test-suite.json"],
@ -117,14 +113,14 @@ export const JavaLanguageWithLegacyDateTime: Language = {
"337ed.json", // Expects less strict serialization (optional milliseconds).
],
skipMiscJSON: true, // Handles edge cases differently and does not allow optional milliseconds.
rendererOptions: {"datetime-provider": "legacy"},
quickTestRendererOptions: [{ "array-type": "list"}],
rendererOptions: { "datetime-provider": "legacy" },
quickTestRendererOptions: [{ "array-type": "list" }],
};
export const JavaLanguageWithLombok: Language = {
...JavaLanguage,
base: "test/fixtures/java-lombok",
quickTestRendererOptions: [{ "array-type": "list", "lombok": "true"}],
quickTestRendererOptions: [{ "array-type": "list", lombok: "true" }],
};
export const PythonLanguage: Language = {
@ -1037,7 +1033,7 @@ export const HaskellLanguage: Language = {
"recursive.json",
"bug427.json",
"nst-test-suite.json",
"keywords.json"
"keywords.json",
],
skipMiscJSON: false,
skipSchema: [
@ -1056,5 +1052,25 @@ export const HaskellLanguage: Language = {
],
rendererOptions: {},
quickTestRendererOptions: [{ "array-type": "list" }],
sourceFiles: ["src/language/Haskell.ts"]
sourceFiles: ["src/language/Haskell.ts"],
};
export const PHPLanguage: Language = {
name: "php",
base: "test/fixtures/php",
runCommand(sample: string) {
return `php main.php \"${sample}\"`;
},
diffViaSchema: false,
skipDiffViaSchema: [],
allowMissingNull: true,
features: ["enum"],
output: "TopLevel.php",
topLevel: "TopLevel",
skipJSON: [],
skipMiscJSON: false,
skipSchema: [],
rendererOptions: {},
quickTestRendererOptions: [],
sourceFiles: ["src/Language/Php.ts"],
};