Skip to content

Commit b46e83d

Browse files
committed
test: distinguish date and time validation
1 parent 4fae346 commit b46e83d

2 files changed

Lines changed: 17 additions & 15 deletions

File tree

‎test/fixtures.ts‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,24 +91,23 @@ function additionalTestFiles(
9191

9292
let fn = `${base}.${extension}`;
9393
tryAdd(fn);
94-
let i = 1;
95-
let found: boolean;
96-
do {
97-
found = false;
98-
94+
const prefix = `${path.basename(base)}.`;
95+
const numberedIndices = fs
96+
.readdirSync(path.dirname(base))
97+
.filter((file) => file.startsWith(prefix))
98+
.map((file) => file.slice(prefix.length).match(/^(\d+)\./)?.[1])
99+
.filter((index): index is string => index !== undefined)
100+
.map(Number);
101+
const maxIndex = Math.max(0, ...numberedIndices);
102+
for (let i = 1; i <= maxIndex; i++) {
99103
fn = `${base}.${i.toString()}.${extension}`;
100-
found = tryAdd(fn) || found;
104+
tryAdd(fn);
101105

102106
for (const feature of features) {
103-
found =
104-
tryAdd(
105-
`${base}.${i.toString()}.fail.${feature}.${extension}`,
106-
) || found;
107+
tryAdd(`${base}.${i.toString()}.fail.${feature}.${extension}`);
107108
}
108-
found = tryAdd(`${base}.${i.toString()}.fail.${extension}`) || found;
109-
110-
i++;
111-
} while (found);
109+
tryAdd(`${base}.${i.toString()}.fail.${extension}`);
110+
}
112111
return additionalFiles;
113112
}
114113

‎test/languages.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ export type LanguageFeature =
4343
| "no-defaults"
4444
| "strict-optional"
4545
| "date-time"
46+
| "date"
47+
| "time"
4648
| "integer"
4749
| "integer-string"
4850
| "bool-string"
@@ -1475,7 +1477,8 @@ export const DartLanguage: Language = {
14751477
name: "dart",
14761478
base: "test/fixtures/dart",
14771479
compileCommandForOptions(options) {
1478-
return options["use-freezed"] === "true"
1480+
return options["use-freezed"] === "true" ||
1481+
options["use-json-annotation"] === "true"
14791482
? "dart pub get && mkdir -p lib && cp TopLevel.dart lib/top_level.dart && sed -i.bak s/TopLevel.dart/top_level.dart/ parser.dart && dart pub run build_runner build --delete-conflicting-outputs && cp lib/top_level*.dart ."
14801483
: undefined;
14811484
},

0 commit comments

Comments
 (0)