|
24 | 24 | @test Base.AnnotatedString(str[3:4]) ==
|
25 | 25 | Base.AnnotatedString("me", [(1:2, :thing => 0x01), (1:2, :all => 0x03)])
|
26 | 26 | @test Base.AnnotatedString(str[3:6]) ==
|
27 |
| - Base.AnnotatedString("me s", [(1:2, :thing => 0x01), (1:4, :all => 0x03), (4:4, :other => 0x02)]) |
28 |
| - @test str == Base.AnnotatedString("some string", [(1:4, :thing => 0x01), (1:11, :all => 0x03), (6:11, :other => 0x02)]) |
| 27 | + Base.AnnotatedString("me s", [(1:2, :thing => 0x01), (4:4, :other => 0x02), (1:4, :all => 0x03)]) |
| 28 | + @test str == Base.AnnotatedString("some string", [(1:4, :thing => 0x01), (6:11, :other => 0x02), (1:11, :all => 0x03)]) |
29 | 29 | @test str != Base.AnnotatedString("some string")
|
30 |
| - @test str != Base.AnnotatedString("some string", [(1:1, :thing => 0x01), (6:6, :other => 0x02), (11:11, :all => 0x03)]) |
| 30 | + @test str != Base.AnnotatedString("some string", [(1:1, :thing => 0x01), (1:11, :all => 0x03), (6:6, :other => 0x02)]) |
31 | 31 | @test str != Base.AnnotatedString("some string", [(1:4, :thing => 0x11), (1:11, :all => 0x13), (6:11, :other => 0x12)])
|
32 | 32 | @test str != Base.AnnotatedString("some thingg", [(1:4, :thing => 0x01), (1:11, :all => 0x03), (6:11, :other => 0x02)])
|
33 | 33 | @test Base.AnnotatedString([Base.AnnotatedChar('a', [:a => 1]), Base.AnnotatedChar('b', [:b => 2])]) ==
|
|
51 | 51 | # @test collect(Base.eachstyle(str)) ==
|
52 | 52 | # [("some", [:thing => 0x01, :all => 0x03]),
|
53 | 53 | # (" string", [:all => 0x03, :other => 0x02])]
|
54 |
| - @test ==(Base.annotatedstring_optimize!( |
55 |
| - Base.AnnotatedString("abc", [(1:1, :val => 1), |
56 |
| - (2:2, :val => 2), |
57 |
| - (2:2, :val => 1), |
58 |
| - (3:3, :val => 2)])), |
59 |
| - Base.AnnotatedString("abc", [(1:2, :val => 1), |
60 |
| - (2:3, :val => 2)])) |
61 | 54 | @test chopprefix(sprint(show, str), "Base.") ==
|
62 |
| - "AnnotatedString{String}(\"some string\", [(1:4, :thing => 0x01), (1:11, :all => 0x03), (6:11, :other => 0x02)])" |
| 55 | + "AnnotatedString{String}(\"some string\", [(1:4, :thing => 0x01), (6:11, :other => 0x02), (1:11, :all => 0x03)])" |
63 | 56 | @test eval(Meta.parse(repr(str))) == str
|
64 | 57 | @test sprint(show, MIME("text/plain"), str) == "\"some string\""
|
65 | 58 | end
|
|
149 | 142 | # Check `annotate!`, including region sorting
|
150 | 143 | @test truncate(aio, 0).io.size == 0
|
151 | 144 | @test write(aio, "hello world") == ncodeunits("hello world")
|
152 |
| - @test Base.annotate!(aio, 7:11, :tag => 2) === aio |
153 | 145 | @test Base.annotate!(aio, 1:5, :tag => 1) === aio
|
| 146 | + @test Base.annotate!(aio, 7:11, :tag => 2) === aio |
154 | 147 | @test Base.annotations(aio) == [(1:5, :tag => 1), (7:11, :tag => 2)]
|
155 | 148 | # Reading
|
156 | 149 | @test read(seekstart(deepcopy(aio.io)), String) == "hello world"
|
@@ -178,24 +171,24 @@ end
|
178 | 171 | @test Base.annotations(aio) == [(1:5, :tag => 1), (7:11, :tag => 2)] # Should be unchanged
|
179 | 172 | @test write(seek(aio, 0), Base.AnnotatedString("hey-o", [(1:5, :hey => 'o')])) == 5
|
180 | 173 | @test read(seekstart(aio), String) == "hey-o alice"
|
181 |
| - @test Base.annotations(aio) == [(1:5, :hey => 'o'), (7:11, :tag => 2)] # First annotation should have been entirely replaced |
| 174 | + @test Base.annotations(aio) == [(7:11, :tag => 2), (1:5, :hey => 'o')] # First annotation should have been entirely replaced |
182 | 175 | @test write(seek(aio, 7), Base.AnnotatedString("bbi", [(1:3, :hey => 'a')])) == 3 # a[lic => bbi]e ('alice' => 'abbie')
|
183 | 176 | @test read(seekstart(aio), String) == "hey-o abbie"
|
184 |
| - @test Base.annotations(aio) == [(1:5, :hey => 'o'), (7:7, :tag => 2), (8:10, :hey => 'a'), (11:11, :tag => 2)] |
| 177 | + @test Base.annotations(aio) == [(7:7, :tag => 2), (11:11, :tag => 2), (1:5, :hey => 'o'), (8:10, :hey => 'a')] |
185 | 178 | @test write(seek(aio, 0), Base.AnnotatedString("ab")) == 2 # Check first annotation's region is adjusted correctly
|
186 | 179 | @test read(seekstart(aio), String) == "aby-o abbie"
|
187 |
| - @test Base.annotations(aio) == [(3:5, :hey => 'o'), (7:7, :tag => 2), (8:10, :hey => 'a'), (11:11, :tag => 2)] |
| 180 | + @test Base.annotations(aio) == [(7:7, :tag => 2), (11:11, :tag => 2), (3:5, :hey => 'o'), (8:10, :hey => 'a')] |
188 | 181 | @test write(seek(aio, 3), Base.AnnotatedString("ss")) == 2
|
189 | 182 | @test read(seekstart(aio), String) == "abyss abbie"
|
190 |
| - @test Base.annotations(aio) == [(3:3, :hey => 'o'), (7:7, :tag => 2), (8:10, :hey => 'a'), (11:11, :tag => 2)] |
| 183 | + @test Base.annotations(aio) == [(7:7, :tag => 2), (11:11, :tag => 2), (3:3, :hey => 'o'), (8:10, :hey => 'a')] |
191 | 184 | # Writing one buffer to another
|
192 | 185 | newaio = Base.AnnotatedIOBuffer()
|
193 | 186 | @test write(newaio, seekstart(aio)) == 11
|
194 | 187 | @test read(seekstart(newaio), String) == "abyss abbie"
|
195 | 188 | @test Base.annotations(newaio) == Base.annotations(aio)
|
196 | 189 | @test write(seek(newaio, 5), seek(aio, 5)) == 6
|
197 |
| - @test Base.annotations(newaio) == Base.annotations(aio) |
| 190 | + @test sort(Base.annotations(newaio)) == sort(Base.annotations(aio)) |
198 | 191 | @test write(newaio, seek(aio, 5)) == 6
|
199 | 192 | @test read(seekstart(newaio), String) == "abyss abbie abbie"
|
200 |
| - @test Base.annotations(newaio) == vcat(Base.annotations(aio), [(13:13, :tag => 2), (14:16, :hey => 'a'), (17:17, :tag => 2)]) |
| 193 | + @test sort(Base.annotations(newaio)) == sort(vcat(Base.annotations(aio), [(13:13, :tag => 2), (14:16, :hey => 'a'), (17:17, :tag => 2)])) |
201 | 194 | end
|
0 commit comments