Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions one-clause/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,20 @@ <h2 data-step="A host without `Io.save` refuses the second module, before any of
the demonstration is a test:
</p>
<pre class="code"><code><span class="d-gutter">// crates/deed-driver/tests/demo.rs</span>
let stopped = call(&amp;module, "process", &amp;[Value::I64(0), Value::I64(0)])
.expect_err("read_write needs a host to provide save");
let mut host = Host::new();
host.offer("deed:io", "read", |_| Ok(Some(Value::I64(0))));

let Trap::NeedsAHost(what) = stopped else {
panic!("it should say what it wanted, not {stopped}");
};</code></pre>
let refused = host
.link(&amp;module_for("read_write.deed"))
.expect_err("a host that cannot save should refuse the module that saves");

assert_eq!(refused.name, "save");</code></pre>
<p>
<code>NeedsAHost</code> carries the name of the operation the module
asked for, and it is reached before any instruction of
<code>process</code> executes.
<code>Host::link</code> reads the whole import list and answers
before an instruction runs. The same host links the read-only module
and hands it back ready to call, which is the other half of it: a
host that refused both would be a host with no filesystem, and that
would say nothing about the clause.
</p>

<h2 data-step="All of it is pinned by tests that run on every commit, including the listing above.">None of this is checked by eye</h2>
Expand All @@ -177,12 +181,14 @@ <h2 data-step="All of it is pinned by tests that run on every commit, including
they run on every commit:
</p>
<pre class="code"><code>$ cargo test -p deed-driver --test demo
running 5 tests
running 7 tests
test read_only_imports_read_and_nothing_else ... ok
test running_read_only_without_a_host_names_read ... ok
test read_write_imports_read_and_save ... ok
test running_read_write_without_save_names_what_it_wanted ... ok
test the_readme_lists_the_imports_the_modules_actually_have ... ok</code></pre>
test a_host_without_save_refuses_read_write_and_names_save ... ok
test the_same_host_links_read_only_without_restriction ... ok
test running_without_a_host_stops_at_the_first_import_either_way ... ok
test the_readme_lists_the_imports_the_modules_actually_have ... ok
test the_readme_lists_the_tests_this_file_declares ... ok</code></pre>
<p>
The last one exists because the listing on this page and in
<a href="https://github.com/deed-lang/deed/blob/main/demo/README.md"
Expand Down