-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparser.rb
51 lines (38 loc) · 1.36 KB
/
parser.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require_relative 'test_helper'
class TestParser < GlyTest
def test_markup_after_header
doc = parse_example 'examples/parser/markup_after_header.gly'
assert_equal 1, doc.header.size
assert doc.header.has_key?('title')
end
def test_markups
doc = parse_example 'examples/parser/markups.gly'
assert doc.scores.empty?
assert_equal "Perhaps", doc.content[0].text
assert_equal "Ave\nCaesar", doc.content[1].text
assert_equal "Ave Crux\n\nspes unica", doc.content[2].text
end
def test_score_markup_order
doc = parse_example 'examples/parser/score_markup_order.gly'
assert_equal 6, doc.content.size
assert_instance_of Gly::Score, doc.content[0]
assert_equal 'a', doc.content[0].headers['id']
assert_instance_of Gly::Markup, doc.content[1]
assert_equal 'a', doc.content[1].text
assert_instance_of Gly::Score, doc.content[2]
assert_equal 'b', doc.content[2].headers['id']
assert_instance_of Gly::Markup, doc.content[3]
assert_equal 'b', doc.content[3].text
assert_instance_of Gly::Markup, doc.content[4]
assert_equal 'c', doc.content[4].text
assert_instance_of Gly::Score, doc.content[5]
assert_equal 'c', doc.content[5].headers['id']
end
def parse_example(path)
doc = nil
File.open expand_test_path(path) do |fr|
doc = Gly::Parser.new.parse(fr)
end
doc
end
end