Bug 1437004 - Updating tokenizer tests to ast v3;r?arai
MozReview-Commit-ID: BbP6n1CwHvs
index 395fdb4476b5632e0445b8e17aa76c3f91c31a57..5b87fcf5548478cbfc1a9651087f881a6b0f1f83
GIT binary patch
literal 94
zc$~8-DJ{rJwX?}cO-!+K%FIj2%uDx7NzE(COv_9yVqjumV8}^KO3h&?OUx-vWw6l)
jE3_#tDFQ0AV+Km6<>%YzL;3ka%?C~?ayr=PLyQFg(T^W2
--- a/js/src/jsapi-tests/testBinASTReader.cpp
+++ b/js/src/jsapi-tests/testBinASTReader.cpp
@@ -242,19 +242,19 @@ runTestFromPath(JSContext* cx, const cha
DumpParseTree(binParsed.unwrap(), binPrinter);
Sprinter txtPrinter(cx);
if (!txtPrinter.init())
MOZ_CRASH("Couldn't display txtParsed");
DumpParseTree(txtParsed, txtPrinter);
if (strcmp(binPrinter.string(), txtPrinter.string()) != 0) {
- fprintf(stderr, "Got distinct ASTs when parsing %s (%lu/%lu):\n\tBINARY\n%s\n\n\tTEXT\n%s\n",
+ fprintf(stderr, "Got distinct ASTs when parsing %s (%p/%p):\n\tBINARY\n%s\n\n\tTEXT\n%s\n",
txtPath.begin(),
- binPrinter.getOffset(), txtPrinter.getOffset(),
+ (void*)binPrinter.getOffset(), (void*)txtPrinter.getOffset(),
binPrinter.string(), txtPrinter.string());
#if 0 // Not for release, but useful for debugging.
// In case of error, this dumps files to /tmp, so they may
// easily be diffed.
auto fd = open("/tmp/bin.ast", O_CREAT | O_TRUNC | O_WRONLY, 0666);
if (!fd)
MOZ_CRASH("Could not open bin.ast");
auto result = write(fd, binPrinter.string(), binPrinter.stringEnd() - binPrinter.string());
@@ -287,14 +287,17 @@ runTestFromPath(JSContext* cx, const cha
#elif defined(XP_UNIX)
if (closedir(dir) != 0)
MOZ_CRASH("Could not close dir");
#endif // defined(XP_WIN)
}
BEGIN_TEST(testBinASTReaderECMAScript2)
{
+#if defined(XP_WIN)
+ runTestFromPath(cx, "jsapi-tests\\binast\\parser\\tester\\");
+#else
runTestFromPath(cx, "jsapi-tests/binast/parser/tester/");
-
+#endif // defined(XP_XIN)
return true;
}
END_TEST(testBinASTReaderECMAScript2)
--- a/js/src/jsapi-tests/testBinTokenReaderTester.cpp
+++ b/js/src/jsapi-tests/testBinTokenReaderTester.cpp
@@ -206,35 +206,27 @@ BEGIN_TEST(testBinTokenReaderTesterSimpl
Tokenizer tokenizer(cx, contents);
{
js::frontend::BinKind tag;
Tokenizer::BinFields fields(cx);
Tokenizer::AutoTaggedTuple guard(tokenizer);
CHECK(tokenizer.enterTaggedTuple(tag, fields, guard));
- CHECK(tag == js::frontend::BinKind::Pattern);
+ CHECK(tag == js::frontend::BinKind::BindingIdentifier);
Maybe<Chars> found_id;
const double EXPECTED_value = 3.1415;
Maybe<double> found_value;
- // Order of fields is not deterministic in the encoder (we could make
- // it deterministic for the test, though, since we already know the binary).
- if (fields[0] == js::frontend::BinField::Id) {
- CHECK(fields[1] == js::frontend::BinField::Value);
- CHECK(tokenizer.readMaybeChars(found_id));
- CHECK(tokenizer.readMaybeDouble(found_value));
- } else if (fields[0] == js::frontend::BinField::Value) {
- CHECK(fields[1] == js::frontend::BinField::Id);
- CHECK(tokenizer.readMaybeDouble(found_value));
- CHECK(tokenizer.readMaybeChars(found_id));
- } else {
- CHECK(false);
- }
+ // Order of fields is deterministic.
+ CHECK(fields[0] == js::frontend::BinField::Label);
+ CHECK(fields[1] == js::frontend::BinField::Value);
+ CHECK(tokenizer.readMaybeChars(found_id));
+ CHECK(tokenizer.readMaybeDouble(found_value));
CHECK(EXPECTED_value == *found_value); // Apparently, CHECK_EQUAL doesn't work on `double`.
CHECK(Tokenizer::equals(*found_id, "foo"));
CHECK(guard.done());
}
return true;
}