Skip to content

Commit

Permalink
Fix macro test
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Nov 28, 2023
1 parent da644b9 commit b1431e6
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions test/test_graphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ end
else
sx = string(x)
sy = string(y)
result = if startswith(sx, r"##")
result = if startswith(sx, r"#")
occursin(sy, sx)
elseif startswith(sy, r"##")
elseif startswith(sy, r"#")
occursin(sx, sy)
else
false
Expand Down Expand Up @@ -153,8 +153,8 @@ end
function _copy_node(tree::Node{T}, id_map::AbstractDict;)::Node{T} where {T}
key = objectid(tree)
is_memoized = haskey(id_map, key)
result = get!(id_map, key) do
begin
function body()
return begin
if tree.degree == 0
if tree.constant
Node(; val=copy(tree.val::T))
Expand All @@ -172,6 +172,16 @@ end
end
end
end
result = if is_memoized
begin
$(Expr(:inbounds, true))
local val = id_map[key]
$(Expr(:inbounds, :pop))
val
end
else
id_map[key] = body()
end
return (((x, _) -> begin
x
end)(result, is_memoized))
Expand Down

0 comments on commit b1431e6

Please sign in to comment.