diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-04-08 10:12:43 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-08 10:12:43 -0400 |
commit | f7fdb90fd51e340ea598c055bb3573d3cdfbdaa8 (patch) | |
tree | 40db117b3a9fd2ac70e3b5551195e21eef464138 /core/libdeno/libdeno_test.cc | |
parent | cdb72afd8d91978573f0fa897844aee853983b44 (diff) |
core: snapshot improvements (#2052)
* Moves how snapshots are supplied to the Isolate. Previously they were
given by Behavior::startup_data() but it was only called once at
startup. It makes more sense (and simplifies Behavior) to pass it to the
constructor of Isolate.
* Adds new libdeno type deno_snapshot instead of overloading
deno_buf.
* Adds new libdeno method to delete snapshot deno_snapshot_delete().
* Renames deno_get_snapshot() to deno_snapshot_new().
* Makes StartupData hold references to snapshots. This was implicit when
it previously held a deno_buf but is made explicit now. Note that
include_bytes!() returns a &'static [u8] and we want to avoid
copying that.
Diffstat (limited to 'core/libdeno/libdeno_test.cc')
-rw-r--r-- | core/libdeno/libdeno_test.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/core/libdeno/libdeno_test.cc b/core/libdeno/libdeno_test.cc index 8949e7f4a..7b936cc32 100644 --- a/core/libdeno/libdeno_test.cc +++ b/core/libdeno/libdeno_test.cc @@ -10,10 +10,10 @@ TEST(LibDenoTest, InitializesCorrectly) { } TEST(LibDenoTest, Snapshotter) { - Deno* d1 = deno_new(deno_config{1, empty, empty, nullptr}); + Deno* d1 = deno_new(deno_config{1, empty_snapshot, empty, nullptr}); deno_execute(d1, nullptr, "a.js", "a = 1 + 2"); EXPECT_EQ(nullptr, deno_last_exception(d1)); - deno_buf test_snapshot = deno_get_snapshot(d1); + deno_snapshot test_snapshot = deno_snapshot_new(d1); deno_delete(d1); Deno* d2 = deno_new(deno_config{0, test_snapshot, empty, nullptr}); @@ -21,7 +21,7 @@ TEST(LibDenoTest, Snapshotter) { EXPECT_EQ(nullptr, deno_last_exception(d2)); deno_delete(d2); - delete[] test_snapshot.data_ptr; + deno_snapshot_delete(test_snapshot); } TEST(LibDenoTest, CanCallFunction) { @@ -249,7 +249,7 @@ TEST(LibDenoTest, CheckPromiseErrors) { } TEST(LibDenoTest, LastException) { - Deno* d = deno_new(deno_config{0, empty, empty, nullptr}); + Deno* d = deno_new(deno_config{0, empty_snapshot, empty, nullptr}); EXPECT_EQ(deno_last_exception(d), nullptr); deno_execute(d, nullptr, "a.js", "\n\nthrow Error('boo');\n\n"); EXPECT_STREQ(deno_last_exception(d), @@ -264,7 +264,7 @@ TEST(LibDenoTest, LastException) { } TEST(LibDenoTest, EncodeErrorBug) { - Deno* d = deno_new(deno_config{0, empty, empty, nullptr}); + Deno* d = deno_new(deno_config{0, empty_snapshot, empty, nullptr}); EXPECT_EQ(deno_last_exception(d), nullptr); deno_execute(d, nullptr, "a.js", "eval('a')"); EXPECT_STREQ( @@ -293,7 +293,7 @@ TEST(LibDenoTest, Shared) { } TEST(LibDenoTest, Utf8Bug) { - Deno* d = deno_new(deno_config{0, empty, empty, nullptr}); + Deno* d = deno_new(deno_config{0, empty_snapshot, empty, nullptr}); // The following is a valid UTF-8 javascript which just defines a string // literal. We had a bug where libdeno would choke on this. deno_execute(d, nullptr, "a.js", "x = \"\xEF\xBF\xBD\""); @@ -318,7 +318,7 @@ TEST(LibDenoTest, LibDenoEvalContextError) { TEST(LibDenoTest, SharedAtomics) { int32_t s[] = {0, 1, 2}; deno_buf shared = {nullptr, 0, reinterpret_cast<uint8_t*>(s), sizeof s, 0}; - Deno* d = deno_new(deno_config{0, empty, shared, nullptr}); + Deno* d = deno_new(deno_config{0, empty_snapshot, shared, nullptr}); deno_execute(d, nullptr, "a.js", "Atomics.add(new Int32Array(Deno.core.shared), 0, 1)"); EXPECT_EQ(nullptr, deno_last_exception(d)); |