@@ -423,88 +423,3 @@ impl MarkdownParser {
423423 self . parse_with ( & mut |byte, _| & text[ byte..] , old_tree)
424424 }
425425}
426-
427- #[ cfg( test) ]
428- mod tests {
429- use tree_sitter:: { InputEdit , Point } ;
430-
431- use super :: * ;
432-
433- #[ test]
434- fn inline_ranges ( ) {
435- let code = "# title\n \n Inline [content].\n " ;
436- let mut parser = MarkdownParser :: default ( ) ;
437- let mut tree = parser. parse ( code. as_bytes ( ) , None ) . unwrap ( ) ;
438-
439- let section = tree. block_tree ( ) . root_node ( ) . child ( 0 ) . unwrap ( ) ;
440- assert_eq ! ( section. kind( ) , "section" ) ;
441- let heading = section. child ( 0 ) . unwrap ( ) ;
442- assert_eq ! ( heading. kind( ) , "atx_heading" ) ;
443- let paragraph = section. child ( 1 ) . unwrap ( ) ;
444- assert_eq ! ( paragraph. kind( ) , "paragraph" ) ;
445- let inline = paragraph. child ( 0 ) . unwrap ( ) ;
446- assert_eq ! ( inline. kind( ) , "inline" ) ;
447- assert_eq ! (
448- tree. inline_tree( & inline)
449- . unwrap( )
450- . root_node( )
451- . child( 0 )
452- . unwrap( )
453- . kind( ) ,
454- "shortcut_link"
455- ) ;
456-
457- let code = "# Title\n \n Inline [content].\n " ;
458- tree. edit ( & InputEdit {
459- start_byte : 2 ,
460- old_end_byte : 3 ,
461- new_end_byte : 3 ,
462- start_position : Point { row : 0 , column : 2 } ,
463- old_end_position : Point { row : 0 , column : 3 } ,
464- new_end_position : Point { row : 0 , column : 3 } ,
465- } ) ;
466- let tree = parser. parse ( code. as_bytes ( ) , Some ( & tree) ) . unwrap ( ) ;
467-
468- let section = tree. block_tree ( ) . root_node ( ) . child ( 0 ) . unwrap ( ) ;
469- assert_eq ! ( section. kind( ) , "section" ) ;
470- let heading = section. child ( 0 ) . unwrap ( ) ;
471- assert_eq ! ( heading. kind( ) , "atx_heading" ) ;
472- let paragraph = section. child ( 1 ) . unwrap ( ) ;
473- assert_eq ! ( paragraph. kind( ) , "paragraph" ) ;
474- let inline = paragraph. child ( 0 ) . unwrap ( ) ;
475- assert_eq ! ( inline. kind( ) , "inline" ) ;
476- assert_eq ! (
477- tree. inline_tree( & inline)
478- . unwrap( )
479- . root_node( )
480- . named_child( 0 )
481- . unwrap( )
482- . kind( ) ,
483- "shortcut_link"
484- ) ;
485- }
486-
487- #[ test]
488- fn markdown_cursor ( ) {
489- let code = "# title\n \n Inline [content].\n " ;
490- let mut parser = MarkdownParser :: default ( ) ;
491- let tree = parser. parse ( code. as_bytes ( ) , None ) . unwrap ( ) ;
492- let mut cursor = tree. walk ( ) ;
493- assert_eq ! ( cursor. node( ) . kind( ) , "document" ) ;
494- assert ! ( cursor. goto_first_child( ) ) ;
495- assert_eq ! ( cursor. node( ) . kind( ) , "section" ) ;
496- assert ! ( cursor. goto_first_child( ) ) ;
497- assert_eq ! ( cursor. node( ) . kind( ) , "atx_heading" ) ;
498- assert ! ( cursor. goto_next_sibling( ) ) ;
499- assert_eq ! ( cursor. node( ) . kind( ) , "paragraph" ) ;
500- assert ! ( cursor. goto_first_child( ) ) ;
501- assert_eq ! ( cursor. node( ) . kind( ) , "inline" ) ;
502- assert ! ( cursor. goto_first_child( ) ) ;
503- assert_eq ! ( cursor. node( ) . kind( ) , "shortcut_link" ) ;
504- assert ! ( cursor. goto_parent( ) ) ;
505- assert ! ( cursor. goto_parent( ) ) ;
506- assert ! ( cursor. goto_parent( ) ) ;
507- assert ! ( cursor. goto_parent( ) ) ;
508- assert_eq ! ( cursor. node( ) . kind( ) , "document" ) ;
509- }
510- }
0 commit comments