Skip to content

Commit 345dc51

Browse files
committed
add tests for striping trainling dots
1 parent 7a94011 commit 345dc51

3 files changed

Lines changed: 40 additions & 8 deletions

File tree

test/datatip.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@test localdatatip("l", 4) == 3 # line
2020
end
2121

22-
# remove dot accessors
22+
# ignore dot accessors
2323
let str = """
2424
function withdots(expr::CSTParser.EXPR)
2525
bind = CSTParser.bindingof(expr.args[1])
@@ -68,8 +68,8 @@
6868
end
6969
end
7070

71-
@testset "toplevel datatips" begin
72-
using Atom: topleveldatatip
71+
@testset "global datatips" begin
72+
using Atom: globaldatatip
7373

7474
## method datatip
7575
@eval Main begin
@@ -81,7 +81,7 @@
8181
datatipmethodtest() = nothing
8282
end
8383

84-
let datatip = topleveldatatip("Main", "datatipmethodtest")
84+
let datatip = globaldatatip("Main", "datatipmethodtest", "datatipmethodtest")
8585
@test datatip isa Vector
8686
firsttip = datatip[1]
8787
secondtip = datatip[2]
@@ -94,11 +94,16 @@
9494
## variable datatip
9595
@eval Main datatipvariabletest = "this string should be shown in datatip"
9696

97-
let datatip = topleveldatatip("Main", "datatipvariabletest")
97+
let datatip = globaldatatip("Main", "datatipvariabletest", "datatipvariabletest")
9898
@test datatip isa Vector
9999
firsttip = datatip[1]
100100
@test firsttip[:type] == :snippet
101101
@test occursin(r"this string should be shown in datatip", firsttip[:value])
102102
end
103+
104+
## strips training dots
105+
let item = globaldatatip("Atom", "SYMBOLSCACHE", "SYMBOLSCACHE")
106+
@test item == globaldatatip("Atom", "SYMBOLSCACHE", "SYMBOLSCACHE.keys")
107+
end
103108
end
104109
end

test/goto.jl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
@test localgotoitem("l", 8)[:line] === 7
3232
end
3333

34-
# remove dot accessors
34+
# ignore dot accessors
3535
let str = """
3636
function withdots(expr::CSTParser.EXPR)
3737
bind = CSTParser.bindingof(expr.args[1])
@@ -245,13 +245,25 @@
245245
end
246246
end
247247

248-
@testset "goto global symbols" begin # toplevel symbol goto & method goto
248+
# bundles `modulegotoitems`, `toplevelgotoitems` and `methodgotoitems`
249+
@testset "goto global symbols" begin
249250
# both the original methods and the toplevel bindings that are overloaded
250251
# in a context module should be shown
251-
let items = globalgotoitems("isconst", "Main.Junk", "", nothing)
252+
let items = globalgotoitems("isconst", "isconst", "Main.Junk", "", nothing)
252253
@test length(items) === 2
253254
@test "isconst(m::Module, s::Symbol)" map(item -> item.text, items) # from Base
254255
@test "Base.isconst(::JunkType)" map(item -> item.text, items) # from Junk
255256
end
257+
258+
# strips trailing dots
259+
let item = globalgotoitems("isconst", "isconst", "Main.Junk", "", nothing)
260+
@test item == globalgotoitems("isconst", "Junk.isconst", "Main.Junk", "", nothing)
261+
@test item == globalgotoitems("isconst", "Main.Junk.isconst", "Main.Junk", "", nothing)
262+
end
263+
let item = globalgotoitems("Junk", "Junk", "Main.Junk", "", nothing)
264+
@test item == globalgotoitems("Junk", "Main.Junk", "Main.Junk", "", nothing)
265+
@test item == globalgotoitems("Junk", "Junk.isconst", "Main.Junk", "", nothing)
266+
@test item == globalgotoitems("Junk", "Main.Junk.isconst", "Main.Junk", "", nothing)
267+
end
256268
end
257269
end

test/utils.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,18 @@ end
9494
@test strlimit("Jμλια in the Nutshell", 21, " ...") == "Jμλια in the Nutshell"
9595
@test strlimit("Jμλια in the Nutshell", 20, " ...") == "Jμλια in the Nut ..."
9696
end
97+
98+
@testset "strip trailing dots" begin
99+
using Atom: striptrailingdots
100+
101+
# only including ASCII
102+
@test striptrailingdots("field", "Head.field") == "Head.field"
103+
@test striptrailingdots("Head", "Head.field") == "Head"
104+
105+
# including Unicode
106+
@test striptrailingdots("fιηλδ", "Hηαδ.fιηλδ") == "Hηαδ.fιηλδ"
107+
@test striptrailingdots("Hηαδ", "Hηαδ.fιηλδ") == "Hηαδ"
108+
109+
# invalid case
110+
@test_nowarn striptrailingdots("foo", "head.field")
111+
end

0 commit comments

Comments
 (0)