Skip to content

Commit a87d4af

Browse files
committed
test: add issue 142 to tests + fix simple example
1 parent a592e4f commit a87d4af

File tree

4 files changed

+39
-4
lines changed

4 files changed

+39
-4
lines changed

README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ See [Type Definition](https://aminya.github.io/AcuteML.jl/dev/#Main-macro-and-I/
4040
# Example - Simple
4141
```julia
4242
using AcuteML
43-
@aml mutable struct Body "~"
43+
44+
# the xml/html name of each property is written in front of it (e.g. "body")
45+
# `~` means that the struct property name is the same as xml/html name
46+
47+
@aml mutable struct Body "body"
4448
h1, "~"
4549
p::Vector{String}, "~"
4650
end
@@ -58,11 +62,11 @@ julia> pprint(d)
5862
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
5963
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
6064
<html>
61-
<Body>
65+
<body>
6266
<h1>My heading</h1>
6367
<p>Paragraph1</p>
6468
<p>Paragraph2</p>
65-
</Body>
69+
</body>
6670
</html>
6771
```
6872

examples/simple.jl

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using AcuteML
2-
@aml mutable struct Body "~"
2+
3+
# `~` means that the struct property name is the same as xml/html name
4+
5+
@aml mutable struct Body "body"
36
h1, "~"
47
p::Vector{String}, "~"
58
end

test/issue_142.jl

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using AcuteML
2+
3+
@aml mutable struct inner "~"
4+
id1::Int, att"~"
5+
desc1::String, "~"
6+
end
7+
8+
@aml mutable struct outer doc"outer"
9+
id2::Int, att"~"
10+
innerList::Vector{inner}, "inner"
11+
end
12+
13+
i1 = inner(id1 = 1, desc1 = "desc1")
14+
i2 = inner(id1 = 2, desc1 = "desc2")
15+
o1 = outer(id2 = 3, innerList = [i1, i2])
16+
pprint(o1)
17+
18+
pprint("./o1.xml", o1)
19+
20+
21+
xml = readxml("./o1.xml")
22+
23+
o2 = outer(xml)
24+
25+
26+
rm("./o1.xml")

test/runtests.jl

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ include("errors.jl")
1717
end
1818
@testset "simple" begin
1919
include("../examples/simple.jl")
20+
21+
include("./issue_142.jl")
2022
end
2123

2224
## MusicXML tests

0 commit comments

Comments
 (0)