Skip to content

Commit

Permalink
🦆 Fix expression equality again
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Dec 9, 2020
1 parent d2706cd commit 81d81be
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/runner/PlutoRunner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ struct Computer
output_globals::Vector{Symbol}
end

expr_hash(e::Expr) = objectid(e.head) + mapreduce(expr_hash, +, enumerate(e.args); init=zero(ObjectID))
expr_hash(e::Expr) = objectid(e.head) + mapreduce(p -> objectid((p[1], expr_hash(p[2]))), +, enumerate(e.args); init=zero(ObjectID))
expr_hash(x) = objectid(x)
# TODO: clear key when a cell is deleted furever
const computers = Dict{ObjectID,Computer}()
Expand Down
15 changes: 15 additions & 0 deletions test/React.jl
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,21 @@ import Distributed
@test old != notebook.cells[6].output_repr

WorkspaceManager.unmake_workspace((🍭, notebook))


@testset "Expression hash" begin
same(a,b) = Pluto.PlutoRunner.expr_hash(a) == Pluto.PlutoRunner.expr_hash(b)

@test same(:(1), :(1))
@test !same(:(1), :(1.0))
@test same(:(x + 1), :(x + 1))
@test !same(:(x + 1), :(x + 1.0))
@test same(:(1 |> a |> a |> a), :(1 |> a |> a |> a))
@test same(:(a(b(1,2))), :(a(b(1,2))))
@test !same(:(a(b(1,2))), :(a(b(1,3))))
@test !same(:(a(b(1,2))), :(a(b(1,1))))
@test !same(:(a(b(1,2))), :(a(b(2,1))))
end
end

@testset "Run multiple" begin
Expand Down

0 comments on commit 81d81be

Please sign in to comment.