summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/gtest/CMakeLists.txt2
-rw-r--r--test/gtest/source-map.cpp (renamed from test/gtest/binary-reader.cpp)36
2 files changed, 13 insertions, 25 deletions
diff --git a/test/gtest/CMakeLists.txt b/test/gtest/CMakeLists.txt
index c3d281f1c..102d3ca2a 100644
--- a/test/gtest/CMakeLists.txt
+++ b/test/gtest/CMakeLists.txt
@@ -3,7 +3,7 @@ include_directories(../../src/wasm)
set(unittest_SOURCES
arena.cpp
- binary-reader.cpp
+ source-map.cpp
cfg.cpp
dfa_minimization.cpp
disjoint_sets.cpp
diff --git a/test/gtest/binary-reader.cpp b/test/gtest/source-map.cpp
index b73fe55bd..c943be172 100644
--- a/test/gtest/binary-reader.cpp
+++ b/test/gtest/source-map.cpp
@@ -14,24 +14,19 @@
* limitations under the License.
*/
-#include "parser/wat-parser.h"
+#include "source-map.h"
#include "print-test.h"
-#include "wasm-binary.h"
#include "gtest/gtest.h"
using namespace wasm;
-using BinaryReaderTest = PrintTest;
+using SourceMapTest = PrintTest;
// Check that debug location parsers can handle single-segment mappings.
-TEST_F(BinaryReaderTest, SourceMappingSingleSegment) {
- auto moduleText = "(module)";
- Module module;
- parseWast(module, moduleText);
-
- BufferWithRandomAccess buffer;
- WasmBinaryWriter(&module, buffer, PassOptions());
- auto moduleBytes = buffer.getAsChars();
+TEST_F(SourceMapTest, SourceMappingSingleSegment) {
+ auto text = "(module)";
+ Module wasm;
+ parseWast(wasm, text);
// A single-segment mapping starting at offset 0.
std::string sourceMap = R"(
@@ -42,22 +37,15 @@ TEST_F(BinaryReaderTest, SourceMappingSingleSegment) {
"mappings": "A"
}
)";
- std::stringstream sourceMapStream(sourceMap);
+ std::vector<char> buffer(sourceMap.begin(), sourceMap.end());
+
+ SourceMapReader reader(buffer);
// Test `readSourceMapHeader` (only check for errors, as there is no mapping
// to print).
- {
- Module module;
- WasmBinaryReader binaryReader(module, FeatureSet::All, moduleBytes);
- binaryReader.setDebugLocations(&sourceMapStream);
- binaryReader.readSourceMapHeader();
- }
+ reader.readHeader(wasm);
// Test `readNextDebugLocation`.
- {
- Module module;
- WasmBinaryReader binaryReader(module, FeatureSet::All, moduleBytes);
- binaryReader.setDebugLocations(&sourceMapStream);
- binaryReader.readNextDebugLocation();
- }
+ // TODO: Actually check the result.
+ reader.readDebugLocationAt(1);
}