Skip to content

Commit be626b3

Browse files
chqrliebvdberg
authored andcommitted
Tester: remove redundant enum prefixes
1 parent c153ccd commit be626b3

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

tools/tester/expect_file.c2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ fn bool ExpectFile.checkLine(ExpectFile* f, u32 line_nr, const char* start, cons
108108
#endif
109109

110110
if (!f.expectedLine) {
111-
if (f.mode == ExpectMode.COMPLETE) {
111+
if (f.mode == COMPLETE) {
112112
color_print2(f.output, colError, " in file %s: line %d\n unexpected line '%s'", f.filename, line_nr, line);
113113
return false;
114114
} else {
@@ -122,7 +122,7 @@ fn bool ExpectFile.checkLine(ExpectFile* f, u32 line_nr, const char* start, cons
122122
f.expIndex++;
123123
f.setExpected();
124124
} else {
125-
if (f.mode == ExpectMode.COMPLETE || f.consecutive) {
125+
if (f.mode == COMPLETE || f.consecutive) {
126126
color_print2(f.output, colError, " in file %s: line %d\n expected '%s'\n got '%s'", f.filename, line_nr, f.expectedLine, line);
127127
return false;
128128
}

tools/tester/test_db.c2

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public fn void Db.init(Db* db,
119119
db.errorMsg = string_buffer.create(128, false, 2);
120120
db.recipe = string_buffer.create(4096, false, 2);
121121

122-
if (kind == TestKind.C2) { // only for single file test
122+
if (kind == C2) { // only for single file test
123123
file_utils.make_path(db.current_file, elemsof(db.current_file), cwd, filename);
124124
}
125125
}
@@ -363,11 +363,11 @@ fn bool Db.parseExpect(Db* db) {
363363
}
364364
db.cur++;
365365
const char* modeStr = db.readWord();
366-
ExpectMode em = ExpectMode.ATLEAST;
366+
ExpectMode em = ATLEAST;
367367
if (same_string(modeStr, "atleast")) {
368-
em = ExpectMode.ATLEAST;
368+
em = ATLEAST;
369369
} else if (same_string(modeStr, "complete")) {
370-
em = ExpectMode.COMPLETE;
370+
em = COMPLETE;
371371
} else {
372372
db.errorMsg.print("unknown mode: %s", modeStr);
373373
return false;
@@ -413,29 +413,29 @@ fn bool Db.parseKeyword(Db* db) {
413413
if (!db.runSkipped) db.skip = true;
414414
return true;
415415
case "recipe":
416-
if (db.kind != TestKind.C2T) {
416+
if (db.kind != C2T) {
417417
db.errorMsg.add("keyword 'recipe' only allowed in .c2t files");
418418
return false;
419419
}
420420
db.cur += 7;
421421
return db.parseRecipe();
422422
case "warnings":
423-
if (db.kind != TestKind.C2) {
423+
if (db.kind != C2) {
424424
db.errorMsg.add("keyword 'warnings' only allowed in .c2 files");
425425
return false;
426426
}
427427
db.recipe.print(" $warnings %s\n", db.readLine());
428428
db.skipLine();
429429
break;
430430
case "file":
431-
if (db.kind == TestKind.C2) {
431+
if (db.kind == C2) {
432432
db.errorMsg.add("keyword 'file' only allowed in .c2t/.c2a files");
433433
return false;
434434
}
435435
db.cur += 4;
436436
return db.parseFile();
437437
case "expect":
438-
if (db.kind != TestKind.C2T && db.kind != TestKind.C2A) {
438+
if (db.kind != C2T && db.kind != C2A) {
439439
db.errorMsg.add("keyword 'expect' only allowed in .c2t/.c2a files");
440440
return false;
441441
}
@@ -489,15 +489,15 @@ fn void Db.parseTags(Db* db, const char* start, const char* end) {
489489
if (!cp) return;
490490
cp += 4; // skip "// @";
491491

492-
Type kind = Type.ERROR;
492+
Type kind = ERROR;
493493
if (strstart(cp, "error{", &cp)) {
494-
kind = Type.ERROR;
494+
kind = ERROR;
495495
} else
496496
if (strstart(cp, "warning{", &cp)) {
497-
kind = Type.WARNING;
497+
kind = WARNING;
498498
} else
499499
if (strstart(cp, "note{", &cp)) {
500-
kind = Type.NOTE;
500+
kind = NOTE;
501501
} else {
502502
db.error("unknown tag, expect note/warning/error");
503503
return;
@@ -542,7 +542,7 @@ fn void Db.parseLineOutside(Db* db, const char* start, const char* end) {
542542
if (cp == end) return;
543543

544544
// TODO if .c2t/.cta, only accept tags or comments
545-
if (db.kind != TestKind.C2 && !strstart(cp, "// ", nil)) {
545+
if (db.kind != C2 && !strstart(cp, "// ", nil)) {
546546
db.error("unexpected line");
547547
return;
548548
}
@@ -554,14 +554,14 @@ fn void Db.parseLineOutside(Db* db, const char* start, const char* end) {
554554
return;
555555
db.recipe.print(" $warnings %s\n", name);
556556
} else if (strstart(cp, "target{", &cp)) {
557-
if (db.kind != TestKind.C2) {
557+
if (db.kind != C2) {
558558
db.error("keyword 'target' only allowed in .c2 files");
559559
return;
560560
}
561561
if (!db.readUntil(db.target, elemsof(db.target), cp, '}', "target"))
562562
return;
563563
} else if (strstart(cp, "file{", &cp)) {
564-
if (db.kind == TestKind.C2) {
564+
if (db.kind == C2) {
565565
db.error("invalid @file tag in .c2 test");
566566
return;
567567
}
@@ -573,21 +573,21 @@ fn void Db.parseLineOutside(Db* db, const char* start, const char* end) {
573573
db.recipe.print(" %s\n", db.current_file);
574574
db.file_start = end + 1;
575575
db.line_offset = db.line_nr;
576-
db.mode = Mode.Infile;
576+
db.mode = Infile;
577577
} else if (strstart(cp, "expect{", &cp)) {
578-
if (db.kind != TestKind.C2T) {
578+
if (db.kind != C2T) {
579579
db.error("invalid @expect tag in .c2/.cta test");
580580
return;
581581
}
582582
char[128] name;
583583
if (!db.readUntil(name, elemsof(name), cp, '}', "filename"))
584584
return;
585-
db.currentExpect = expect_file.create(name, ExpectMode.ATLEAST);
585+
db.currentExpect = expect_file.create(name, ATLEAST);
586586
// TODO check for name duplicates
587587
db.addExpected(db.currentExpect);
588-
db.mode = Mode.InExpectFile;
588+
db.mode = InExpectFile;
589589
} else if (strstart(cp, "backend c", &cp)) {
590-
if (db.kind != TestKind.C2T) {
590+
if (db.kind != C2T) {
591591
db.error("invalid @backend c tag in .c2/c2a test");
592592
return;
593593
}
@@ -612,7 +612,7 @@ fn void Db.parseLineFile(Db* db, const char* start, const char* end) {
612612
const char* file_end = start;
613613
db.writeFile(db.current_file, db.file_start, (u32)(file_end - db.file_start));
614614
db.file_start = nil;
615-
db.mode = Mode.Outside;
615+
db.mode = Outside;
616616
db.parseLine(start, end);
617617
return;
618618
}
@@ -624,7 +624,7 @@ fn void Db.parseLineExpect(Db* db, const char* start, const char* end) {
624624
// if line starts with '// @' stop InExpectFile mode
625625
if (strstart(start, "// @", nil)) {
626626
db.currentExpect = nil;
627-
db.mode = Mode.Outside;
627+
db.mode = Outside;
628628
db.parseLine(start, end);
629629
return;
630630
}

tools/tester/tester.c2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ fn u32 online_cpus() {
143143
fn void handle_file(TestQueue* queue, const char* filename) {
144144
TestKind kind;
145145
if (endsWith(filename, ".c2")) {
146-
kind = TestKind.C2;
146+
kind = C2;
147147
} else if (endsWith(filename, ".c2t")) {
148-
kind = TestKind.C2T;
148+
kind = C2T;
149149
} else if (endsWith(filename, ".c2a")) {
150-
kind = TestKind.C2A;
150+
kind = C2A;
151151
} else {
152152
return;
153153
}

0 commit comments

Comments
 (0)