Skip to content

Commit

Permalink
Merge pull request #12 from JuliaPluto/mde-fix-2
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp authored Oct 21, 2024
2 parents d1b8b26 + 7ce38a4 commit 19d100c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
13 changes: 11 additions & 2 deletions src/Errors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,18 @@ end

function MultipleDefinitionsError(topology::NotebookTopology, cell::AbstractCell, all_definers)
competitors = setdiff(all_definers, [cell])
defs(c) = topology.nodes[c].funcdefs_without_signatures topology.nodes[c].definitions

dd(c) = topology.nodes[c].definitions
df(c) = topology.nodes[c].funcdefs_with_signatures
ddf(c) = topology.nodes[c].definitions topology.nodes[c].funcdefs_without_signatures

MultipleDefinitionsError(
union((defs(cell) defs(c) for c in competitors)...)
union!(
Set{Symbol}(),
(dd(cell) ddf(c) for c in competitors)...,
(ddf(cell) dd(c) for c in competitors)...,
((funcdef.name.joined for funcdef in df(cell) df(c)) for c in competitors)...,
)
)
end

Expand Down
37 changes: 34 additions & 3 deletions test/pluto integration/React.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PlutoDependencyExplorer: CyclicReferenceError, MultipleDefinitionsError

### MORE TESTS ARE IN PLUTO.jL
# The tests on the Pluto side are tests that rely more heavily on what Pluto implements on top of PlutoDependencyExplorer.
# The tests in PlutoDependencyExplorer are focus in *reactive ordering*.
# The tests in PlutoDependencyExplorer focus on *reactive ordering*.

order_to_run(notebook, id::Integer) = order_to_run(notebook, [id])
function order_to_run(notebook, idx)
Expand Down Expand Up @@ -39,7 +39,7 @@ end
@test notebook.cells[1] |> noerror
@test notebook.cells[2] |> noerror

# https://github.com/fonsp/Pluto.jl/issues/26
# https://github.com/fonsp/Pluto.jl/issues/26
setcode!(notebook.cells[1], "x = 1")
update_run!(🍭, notebook, notebook.cells[1])
setcode!(notebook.cells[2], "x")
Expand Down Expand Up @@ -376,6 +376,19 @@ end
e13=27
e14
end"""),

Cell("""
begin
ppp = 28
Base.zero(::YAY) = 28
end
"""),
Cell("""
begin
ppp = 29
Base.zero(::NOO) = 29
end
"""),
])

update_run!(🍭, notebook, notebook.cells[1:4])
Expand Down Expand Up @@ -496,7 +509,7 @@ end
update_run!(🍭, notebook, notebook.cells[20])
@test occursinerror("Multiple definitions", notebook.cells[19])
@test occursinerror("Multiple definitions", notebook.cells[20])
@test occursinerror("asdf", notebook.cells[20])
@test occursinerror("asdf", notebook.cells[19])
@test occursinerror("asdf", notebook.cells[20])
@test notebook.cells[21].errored == true
@test notebook.cells[22].errored == true
Expand Down Expand Up @@ -535,6 +548,24 @@ end
setcode!(notebook.cells[23], "@assert !any(isdefined.([@__MODULE__], [Symbol(:e,i) for i in 1:14]))")
update_run!(🍭, notebook, notebook.cells[23])
@test notebook.cells[23] |> noerror

update_run!(🍭, notebook, notebook.cells[28:29])
@test occursinerror("Multiple definitions", notebook.cells[28])
@test occursinerror("Multiple definitions", notebook.cells[29])
@test occursinerror("ppp", notebook.cells[28])
@test occursinerror("ppp", notebook.cells[29])
@test !occursinerror("zero", notebook.cells[28])
@test !occursinerror("zero", notebook.cells[29])

setcode!(notebook.cells[29], replace(notebook.cells[29].code, "NOO" => "YAY"))
update_run!(🍭, notebook, notebook.cells[29])
@test occursinerror("Multiple definitions", notebook.cells[28])
@test occursinerror("Multiple definitions", notebook.cells[29])
@test occursinerror("ppp", notebook.cells[28])
@test occursinerror("ppp", notebook.cells[29])
@test occursinerror("zero", notebook.cells[28])
@test occursinerror("zero", notebook.cells[29])


WorkspaceManager.unmake_workspace((🍭, notebook); verbose=false)

Expand Down

2 comments on commit 19d100c

@fonsp
Copy link
Member Author

@fonsp fonsp commented on 19d100c Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/117780

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.5 -m "<description of version>" 19d100c4a3ef406e7a590ca66d631a6f38086d4d
git push origin v1.0.5

Please sign in to comment.