Skip to content

Commit

Permalink
Get tests passing with latest Orb
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyalIcing committed Jan 17, 2024
1 parent 03f9320 commit 1fb2df9
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 73 deletions.
10 changes: 5 additions & 5 deletions lib/components_guide/collected_repo.ex
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
defmodule ComponentsGuide.CollectedRepo do
def has?(_content_id), do: raise(:todo)
def get!(_content_id), do: raise(:todo)
def has?(_content_id), do: raise("todo")
def get!(_content_id), do: raise("todo")

def run_isolated!(_content_id), do: raise(:todo)
def run_isolated!(_content_id), do: raise("todo")

def new_instance_definition(_content_id, _imports), do: raise(:unimplemented)
def new_instance_definition(_content_id, _imports), do: raise("unimplemented")
# Replace with a gen server
def start_instance(_instance_definition), do: raise(:unimplemented)
def start_instance(_instance_definition), do: raise("unimplemented")
end
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ defmodule ComponentsGuide.Wasm.Examples.LabSwatch do
# funcp :f32, format_f32(f: F32, ptr: I32), I32
# end

defmodule Math do
use Orb.Import

defw(powf32(a: F32, b: F32), F32)
end
Orb.importw(ColorConversion.Math, :math)

wasm_import(:format,
f32: Orb.DSL.funcp(name: :format_f32, params: {F32, I32}, result: I32)
Expand Down
2 changes: 1 addition & 1 deletion lib/components_guide/wasm/examples/examples_html.ex
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ defmodule ComponentsGuide.Wasm.Examples.HTML do
~S[<output class="flex p-4 bg-gray-800">]

1 ->
call(:i32toa, @count)
typed_call(I32, :i32toa, [@count])

2 ->
~S[</output>]
Expand Down
55 changes: 0 additions & 55 deletions lib/components_guide/wasm/examples/examples_wasi.ex

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule ComponentsGuide.Wasm.PodcastFeed do
use ComponentsGuide.Wasm.PodcastFeed.XMLFormatter, as: XML
require SilverOrb.Arena

Memory.pages(10)
Memory.pages(64)

SilverOrb.BumpAllocator.export_alloc()

Expand Down
2 changes: 1 addition & 1 deletion test/components_guide/wasm/examples/color_picker_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ defmodule ComponentsGuide.Wasm.Examples.ColorPickerTest do
end

test "LabSwatch" do
# IO.puts(LabSwatch.to_wat())
IO.puts(LabSwatch.to_wat())
# IO.inspect(LabSwatch.to_html())
assert is_binary(LabSwatch.to_wasm())

Expand Down
2 changes: 1 addition & 1 deletion test/components_guide/wasm/examples/examples_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ defmodule ComponentsGuide.Wasm.ExamplesTest do
assert HTTPProxy.to_wat() =~
~S"""
(module $HTTPProxy
(import "http" "get" (func $http_get (param i32) (result i32)))
(import "http" "get" (func $ComponentsGuide.Wasm.Examples.HTTPProxy.Fetch.get (param $a i32) (result i32)))
(global $input_offset (export "input_offset") (mut i32) (i32.const 65536))
"""
end
Expand Down
8 changes: 6 additions & 2 deletions test/components_guide/wasm/examples/podcast_feed_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,18 @@ defmodule ComponentsGuide.Wasm.PodcastFeed.Test do
# assert "Description for 2" = xml_xpath(item1, "//enclosure[1]")
end

test "500 episodes" do
inst = Instance.run(PodcastFeed, wasm_imports(episodes_count: 500))
test "12,000 episodes" do
inst = Instance.run(PodcastFeed, wasm_imports(episodes_count: 12_000))
text_xml_func = Instance.capture(inst, String, :text_xml, 0)
text_xml = text_xml_func.()

assert text_xml =~ ~S"""
<?xml version="1.0" encoding="UTF-8"?>
"""

root = xml_parse(text_xml)
items = xml_xpath(root, "//item")
assert 12_000 = length(items)
end

defp xml_parse(xml) do
Expand Down
Binary file modified test/components_guide/wasm/examples/podcast_feed_xml.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion test/components_guide/wasm/examples/podcast_feed_xml.wat
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@
call 22
call 19
call 18)
(memory (;0;) 12)
(memory (;0;) 66)
(global (;0;) (mut i32) (i32.const 65536))
(global (;1;) (mut i32) (i32.const 0))
(global (;2;) (mut i32) (i32.const 0))
Expand Down
Binary file modified test/components_guide/wasm/examples/podcast_feed_xml_OPT.wasm
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@
call 8
call 7
call 6)
(memory (;0;) 12)
(memory (;0;) 66)
(global (;0;) (mut i32) (i32.const 65536))
(global (;1;) (mut i32) (i32.const 0))
(global (;2;) (mut i32) (i32.const 0))
Expand Down

0 comments on commit 1fb2df9

Please sign in to comment.