Skip to content
This repository has been archived by the owner on Oct 4, 2022. It is now read-only.

Rewrite tree unit tests to use the YAML-string to tree parser. #2112

Open
hansjovis opened this issue Jan 28, 2019 · 0 comments
Open

Rewrite tree unit tests to use the YAML-string to tree parser. #2112

hansjovis opened this issue Jan 28, 2019 · 0 comments
Labels
component: parse tree innovation Innovative issue. Relating to performance, memory or data-flow. technical debt

Comments

@hansjovis
Copy link
Contributor

In #2110 a way to parse YAML-strings to a structured tree is introduced.
We should rewrite the unit tests that build and compare trees to use this new functionality.

Example:

	it( "can build a tree from HTML source code", () => {
		const html = "<section>This? is a section.</section>";

		const paragraph = new Paragraph();
		paragraph.sourceStartIndex = 9;
		paragraph.sourceEndIndex = 28;
		paragraph.text = "This? is a section.";

		const section = new StructuredNode( "section" );
		section.sourceStartIndex = 0;
		section.sourceEndIndex = 38;
		section.children = [ paragraph ];

		const expected = new StructuredNode( "root" );
		expected.sourceStartIndex = 0;
		expected.sourceEndIndex = 38;
		expected.children = [ section ];

		const tree = buildTree( html );

		expect( tree.toString() ).toEqual( expected.toString() );
	} );

Should be transformed to:

	it( "can build a tree from HTML source code", () => {
		const html = "<section>This? is a section.</section>";
                cons expected = buildTreeFromYaml`
Structured:
  tag: root
  sourceStartIndex: 9
  sourceEndIndex: 38
  children:
    - Structured:
         tag: section
         sourceStartIndex: 0
         sourceEndIndex: 38
         children:
           - Paragraph:
                sourceStartIndex: 9
                sourceEndIndex: 28
                text: This? is a section.
`;
		const tree = buildTree( html );
		expect( tree.toString() ).toEqual( expected.toString() );
	} );

requires #2081

@manuelaugustin manuelaugustin added component: parse tree innovation Innovative issue. Relating to performance, memory or data-flow. labels Feb 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: parse tree innovation Innovative issue. Relating to performance, memory or data-flow. technical debt
Projects
None yet
Development

No branches or pull requests

2 participants