-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update for v0.7 support #13
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ module InternedStrings | |
export @i_str, intern | ||
|
||
Base.@deprecate_binding(InternedString, String, true) | ||
#InternedString(s)=intern(String(s)) | ||
|
||
@static if VERSION < v"0.7.0-DEV" | ||
const Nothing = Void | ||
|
@@ -98,6 +97,7 @@ end | |
|
||
|
||
macro i_str(s) | ||
# This is done to get interpolation to work correctly | ||
true_string_expr = esc(Meta.parse(string('"', unescape_string(s), '"'))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A comment is likely wanted here explaining that is is making interpolation happen There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, will add. |
||
Expr(:call, intern, true_string_expr) | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ end | |
@test s == s | ||
@test s == "Hello My Friends1" | ||
|
||
@test object_id_eq(intern(s), s) | ||
@test addr_eq(intern(s), s) | ||
end end | ||
|
||
|
||
|
@@ -30,46 +30,32 @@ end end | |
empty!(InternedStrings.pool) | ||
|
||
# sanity check that strings are not already Interning | ||
V6_COMPAT ? (@test !object_id_eq(a, b)) : (@test_broken !object_id_eq(a, b)) | ||
@test !addr_eq(a, b) | ||
|
||
ai = intern(a) | ||
bi = intern(b) | ||
@test object_id_eq(ai, bi) | ||
@test addr_eq(ai, bi) | ||
|
||
@test intern("a $(2*54) c") == "a 108 c" | ||
end | ||
end | ||
|
||
#= | ||
a = "Gold" | ||
typeof(a), objectid(a) # This is the orignal reference | ||
a = intern(a) | ||
typeof(a), objectid(a) # No change still same memory | ||
b = "Gold" | ||
typeof(b),objectid(b) # New memory, see different ID | ||
b = intern(b) # Replace it, now the memory with id= can be freed | ||
typeof(b),objectid(b) # See it is same memory as for the original `a` | ||
objectid(intern("Gold")) # Same again | ||
=# | ||
|
||
@testset "ID check" begin | ||
let a = "Gold", b = "Gold" | ||
let a = "Gold", b = String(b"Gold") | ||
|
||
empty!(InternedStrings.pool) | ||
|
||
target_id = objectid(a) | ||
target_addr = pointer(a) | ||
|
||
a = intern(a) | ||
@test objectid(a) == target_id | ||
@test pointer(a) == target_addr | ||
|
||
(V6_COMPAT | ||
? (@test objectid(b) != target_id) | ||
: (@test_broken !object_id_eq(objectid(b), target_id))) | ||
@test pointer(b) != target_addr | ||
|
||
b = intern(b) | ||
@test objectid(b) == target_id | ||
@test pointer(b) == target_addr | ||
|
||
@test objectid(intern("Gold")) == target_id | ||
@test pointer(intern(SubString("Gold", 1))) == target_addr | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is a different test. And it is now out of sync with that, but I'll replace it anyway There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I didn't realize that interning |
||
|
||
use(a,b) | ||
end | ||
|
@@ -89,7 +75,7 @@ end end | |
@test length(InternedStrings.pool)==0 | ||
ai = intern("Hello My Friends4") | ||
bi = intern(join(["Hello", "My", "Friends4"], " ")) | ||
@test object_id_eq(ai, bi) | ||
@test addr_eq(ai, bi) | ||
@test length(InternedStrings.pool)==1 | ||
use(ai,bi) | ||
ai = [44] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use just CodeCov and not Coveralls?
I don't see the point in having both, and I'm a bit more used to CodeCov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine, I've just copied that for that last 3 years from other packages!
I'll remove Coveralls.