@@ -61,12 +61,12 @@ frontend::CompilationResult compile(nlohmann::json const &configJson, std::files
61
61
[[nodiscard]] TestResult runUpdate (nlohmann::json const &configJson, std::filesystem::path const &tsPath,
62
62
std::filesystem::path const &expectedOutPath) {
63
63
frontend::CompilationResult const ret = compile (configJson, tsPath);
64
- if (ret.m == nullptr ) {
64
+ if (ret.m . invalid () ) {
65
65
if (configJson.contains (" stderr" )) {
66
66
return TestResult::Success;
67
67
} else {
68
68
fmt::println (" FAILED '{}': expected to compile successfully\n error message: {}" , tsPath.c_str (),
69
- * ret.errorMessage );
69
+ ret.errorMessage );
70
70
return TestResult::Failure;
71
71
}
72
72
}
@@ -80,7 +80,7 @@ frontend::CompilationResult compile(nlohmann::json const &configJson, std::files
80
80
[[nodiscard]] TestResult runCompilationErrorCase (nlohmann::json const &configJson,
81
81
std::filesystem::path const &tsPath) {
82
82
frontend::CompilationResult const ret = compile (configJson, tsPath);
83
- if (ret.m != nullptr ) {
83
+ if (ret.m . valid () ) {
84
84
fmt::println (" '{}' success to compile but expect failed" , tsPath.c_str ());
85
85
return TestResult::Failure;
86
86
}
@@ -94,12 +94,11 @@ frontend::CompilationResult compile(nlohmann::json const &configJson, std::files
94
94
}
95
95
}
96
96
97
- std::string const &actualStderr = *ret.errorMessage ;
98
97
size_t lastIndex = 0 ;
99
98
bool failed = false ;
100
99
for (auto const &expectedErrorMessageLineJson : configJson[" stderr" ].get <nlohmann::json::array_t >()) {
101
100
std::string const expectedErrorMessageLine = expectedErrorMessageLineJson.get <std::string>();
102
- size_t index = actualStderr .find (expectedErrorMessageLine, lastIndex);
101
+ size_t index = ret. errorMessage .find (expectedErrorMessageLine, lastIndex);
103
102
if (index == std::string::npos) {
104
103
fmt::println (" \t missing pattern '{}' in stderr." , expectedErrorMessageLine);
105
104
failed = true ;
@@ -111,7 +110,7 @@ frontend::CompilationResult compile(nlohmann::json const &configJson, std::files
111
110
fmt::println (" \t ========== actual error message==========\n "
112
111
" {}"
113
112
" \t ========== actual error message==========" ,
114
- actualStderr );
113
+ ret. errorMessage );
115
114
fmt::println (" FAILED '{}': stderr mismatch" , tsPath.c_str ());
116
115
return TestResult::Failure;
117
116
}
@@ -121,8 +120,8 @@ frontend::CompilationResult compile(nlohmann::json const &configJson, std::files
121
120
[[nodiscard]] TestResult runSnapshotCase (nlohmann::json const &configJson, std::filesystem::path const &tsPath,
122
121
std::filesystem::path const &expectedOutPath) {
123
122
frontend::CompilationResult const ret = compile (configJson, tsPath);
124
- if (ret.m == nullptr ) {
125
- fmt::println (" FAILED '{}': expected to compile successfully\n error message: {}" , tsPath.c_str (), * ret.errorMessage );
123
+ if (ret.m . invalid () ) {
124
+ fmt::println (" FAILED '{}': expected to compile successfully\n error message: {}" , tsPath.c_str (), ret.errorMessage );
126
125
return TestResult::Failure;
127
126
}
128
127
std::stringstream ss;
0 commit comments