File tree Expand file tree Collapse file tree 2 files changed +67
-15
lines changed Expand file tree Collapse file tree 2 files changed +67
-15
lines changed Original file line number Diff line number Diff line change @@ -71,11 +71,22 @@ page_task
7171 = '+'
7272 space ?
7373 description : description
74- tests : task_test *
75- hints : task_hint *
74+ actions : task_actions *
7675 break ?
7776
78- { return { description, tests, hints }; }
77+ { let task = { description, tests: [], hints: [] };
78+ actions .forEach (({type, value}) => task[type].push (value));
79+ return task;
80+ }
81+
82+ page_actions
83+ = page_onComplete
84+ / page_import
85+
86+ task_actions
87+ = test : task_test
88+ / hint : task_hint
89+ / action : task_action
7990
8091info_title
8192 = '#'
@@ -95,15 +106,6 @@ description
95106 break
96107 { return adjust (description); }
97108
98- page_actions
99- = page_onComplete
100- / page_import
101-
102- task_actions
103- = task_test
104- / task_hint
105- / task_action
106-
107109task_test
108110 = '@test'
109111 '('
@@ -112,13 +114,15 @@ task_test
112114 quote
113115 ')'
114116 break
115- { return testPath .join (' ' ); }
117+ { return { type : ' tests ' , value : testPath .join (' ' ) } ; }
116118
117119task_hint
118120 = '@hint'
119121 hint : [^\n ^\r ]+
120122 break
121- { return trimBracketsAndQuotes (hint .join (' ' )); }
123+ { let h = trimBracketsAndQuotes (hint .join (' ' ));
124+ return { type: ' hints' , value: h };
125+ }
122126
123127task_action
124128 = '@action'
@@ -136,7 +140,7 @@ page_import
136140 break
137141 { return filePath .join (' ' ); }
138142
139-
143+
140144// characters
141145
142146content = [^#^@^+] [^\n ^\r ]+ [\n\r ]
Original file line number Diff line number Diff line change @@ -46,3 +46,51 @@ description
4646 const result = parse ( data ) ;
4747 t . deepEqual ( result . pages [ 0 ] . tasks , expected ) ;
4848} ) ;
49+
50+ test ( 'parses a task hint before a test' , t => {
51+ const data = `# Title
52+ description
53+
54+ ## Page One
55+ description
56+
57+ + Task One
58+ @test('01, 02')
59+ @hint('do something')
60+ ` ;
61+ const expected = [ {
62+ description : 'Task One' ,
63+ tests : [
64+ '01, 02'
65+ ] ,
66+ hints : [
67+ 'do something'
68+ ]
69+ } ] ;
70+ const result = parse ( data ) ;
71+ t . deepEqual ( result . pages [ 0 ] . tasks , expected ) ;
72+ } ) ;
73+
74+ test ( 'parses a task test before a hint' , t => {
75+ const data = `# Title
76+ description
77+
78+ ## Page One
79+ description
80+
81+ + Task One
82+ @hint('do something')
83+ @test('01, 02')
84+ ` ;
85+ const expected = [ {
86+ description : 'Task One' ,
87+ tests : [
88+ '01, 02'
89+ ] ,
90+ hints : [
91+ 'do something'
92+ ]
93+ } ] ;
94+ const result = parse ( data ) ;
95+ t . deepEqual ( result . pages [ 0 ] . tasks , expected ) ;
96+ } ) ;
You can’t perform that action at this time.
0 commit comments