-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests for line number and docstring preservation
- Loading branch information
Showing
5 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
*.jl.mem | ||
examples/.ipynb_checkpoints | ||
docs/build | ||
Manifest.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using ResumableFunctions | ||
using Test | ||
using MacroTools: postwalk | ||
|
||
before = :(function f(arg, arg2::Int) | ||
@yield arg | ||
for i in 1:10 | ||
let i=i | ||
@yield arg2 | ||
arg2 = arg2 + i | ||
end | ||
end | ||
while true | ||
try | ||
@yield arg2 | ||
arg2 = arg2 + 1 | ||
catch e | ||
@yield e | ||
arg2 = arg2 + 1 | ||
end | ||
break | ||
end | ||
arg2+arg | ||
@yield arg2 | ||
end | ||
) | ||
|
||
after = eval(quote @macroexpand @resumable $before end) | ||
|
||
function get_all_linenodes(expr) | ||
nodes = Set() | ||
postwalk(expr) do x | ||
if x isa LineNumberNode | ||
push!(nodes, x) | ||
end | ||
x | ||
end | ||
return nodes | ||
end | ||
|
||
@testset "all line numbers are preserved" begin | ||
@test get_all_linenodes(before) ⊆ get_all_linenodes(after) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters