First attempt at Python port, expand tests.
This commit is contained in:
		@@ -28,29 +28,30 @@ async function loadTests(path) {
 | 
			
		||||
        const propertyLevel = level()
 | 
			
		||||
        if (match('input')) {
 | 
			
		||||
          // TODO: Find a way to handle newlines better.
 | 
			
		||||
          if (tail().startsWith('literal')) {
 | 
			
		||||
          if (tail()) {
 | 
			
		||||
            test.input = tail()
 | 
			
		||||
              .split('literal ').join('')
 | 
			
		||||
              .replaceAll('\\n', '\n')
 | 
			
		||||
              .replaceAll('\\t', '\t')
 | 
			
		||||
            continue
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          while (await next(propertyLevel)) test.input.push(line(propertyLevel))
 | 
			
		||||
          test.input = test.input.join('\n').trim()
 | 
			
		||||
          while (await next(propertyLevel)) test.input.push(line(propertyLevel + 1))
 | 
			
		||||
          test.input = test.input.join('\n').trimEnd()
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (match('output')) {
 | 
			
		||||
          // TODO: Find a way to handle newlines better.
 | 
			
		||||
          if (tail().startsWith('literal')) {
 | 
			
		||||
            test.output = tail().split('literal ').join('').replace('\\n', '\n')
 | 
			
		||||
            continue
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          while (await next(propertyLevel)) test.output.push(line())
 | 
			
		||||
          while (await next(propertyLevel)) test.output.push(line(propertyLevel + 1))
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      test.output = test.output.join('\n').trim()
 | 
			
		||||
 | 
			
		||||
      test.input = test.input
 | 
			
		||||
        .replaceAll('\\n', '\n')
 | 
			
		||||
        .replaceAll('\\t', '\t')
 | 
			
		||||
        .replaceAll('\\s', ' ')
 | 
			
		||||
 | 
			
		||||
      test.output = test.output.join('\n').trimEnd()
 | 
			
		||||
        .replaceAll('\\n', '\n')
 | 
			
		||||
        .replaceAll('\\t', '\t')
 | 
			
		||||
        .replaceAll('\\s', ' ')
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -64,6 +65,7 @@ function callTest(pkg, name, input) {
 | 
			
		||||
      input
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    // TODO: Find a way to clean all this trimming up. Most caused by VSCode happily trimming empty spaces off the ends of lines.
 | 
			
		||||
    resolve(stdout.toString().trim())
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
@@ -80,4 +82,4 @@ for (const [name, tests] of Object.entries(descriptions)) {
 | 
			
		||||
      })
 | 
			
		||||
    }
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										166
									
								
								test/tests.tce
									
									
									
									
									
								
							
							
						
						
									
										166
									
								
								test/tests.tce
									
									
									
									
									
								
							@@ -1,54 +1,130 @@
 | 
			
		||||
#schema test
 | 
			
		||||
 | 
			
		||||
describe LineData
 | 
			
		||||
  it Handles a blank line at indent level 0
 | 
			
		||||
    key linedata:basic
 | 
			
		||||
    packages js
 | 
			
		||||
    input literal \n
 | 
			
		||||
    output
 | 
			
		||||
      level: 0 | head:  | tail:  | line:
 | 
			
		||||
 it Handles a blank line at indent level 0
 | 
			
		||||
  key linedata:basic
 | 
			
		||||
  packages js python
 | 
			
		||||
  input \n
 | 
			
		||||
  output
 | 
			
		||||
   | level 0 | indent   | offsetHead 0 | offsetTail 0 | line  |
 | 
			
		||||
 | 
			
		||||
  it Handles a blank line with a single space at indent level 1
 | 
			
		||||
    key linedata:basic
 | 
			
		||||
    packages js
 | 
			
		||||
    input literal  \n
 | 
			
		||||
    output
 | 
			
		||||
      level: 1 | head:  | tail:  | line:
 | 
			
		||||
 it Handles a blank line with a single space
 | 
			
		||||
  key linedata:basic
 | 
			
		||||
  packages js python
 | 
			
		||||
  input \s
 | 
			
		||||
  output
 | 
			
		||||
   | level 1 | indent   | offsetHead 1 | offsetTail 1 | line   |
 | 
			
		||||
 | 
			
		||||
  it Handles a blank line with two spaces
 | 
			
		||||
    key linedata:basic
 | 
			
		||||
    packages js
 | 
			
		||||
    input literal   \n
 | 
			
		||||
    output
 | 
			
		||||
      level: 2 | head:  | tail:  | line:
 | 
			
		||||
 it Handles a blank line with two spaces
 | 
			
		||||
  key linedata:basic
 | 
			
		||||
  packages js python
 | 
			
		||||
  input \s\s
 | 
			
		||||
  output
 | 
			
		||||
   | level 2 | indent   | offsetHead 2 | offsetTail 2 | line    |
 | 
			
		||||
 | 
			
		||||
  it Handles a normal line at indent level 1
 | 
			
		||||
    key linedata:basic
 | 
			
		||||
    packages js
 | 
			
		||||
    input literal  line 1
 | 
			
		||||
    output
 | 
			
		||||
      level: 1 | head: line | tail: 1 | line: line 1
 | 
			
		||||
 it Handles a normal line at indent level 0
 | 
			
		||||
  key linedata:basic
 | 
			
		||||
  packages js python
 | 
			
		||||
  input
 | 
			
		||||
   line 1
 | 
			
		||||
  output
 | 
			
		||||
   | level 0 | indent   | offsetHead 0 | offsetTail 4 | line line 1 |
 | 
			
		||||
 | 
			
		||||
  it Handles a normal line at indent level 1 indented with tabs
 | 
			
		||||
    key linedata:tabs
 | 
			
		||||
    packages js
 | 
			
		||||
    input literal \tline 1
 | 
			
		||||
    output
 | 
			
		||||
      level: 1 | head: line | tail: 1 | line: line 1
 | 
			
		||||
 it Handles a normal line at indent level 1
 | 
			
		||||
  key linedata:basic
 | 
			
		||||
  packages js python
 | 
			
		||||
  input
 | 
			
		||||
    line 1
 | 
			
		||||
  output
 | 
			
		||||
   | level 1 | indent   | offsetHead 1 | offsetTail 5 | line  line 1 |
 | 
			
		||||
 | 
			
		||||
  it Handles a normal line at indent level 2 indented with tabs
 | 
			
		||||
    key linedata:tabs
 | 
			
		||||
    packages js
 | 
			
		||||
    input literal \t\tline 1
 | 
			
		||||
    output
 | 
			
		||||
      level: 2 | head: line | tail: 1 | line: line 1
 | 
			
		||||
 it Handles a normal line at indent level 2
 | 
			
		||||
  key linedata:basic
 | 
			
		||||
  packages js python
 | 
			
		||||
  input
 | 
			
		||||
     line 1
 | 
			
		||||
  output
 | 
			
		||||
   | level 2 | indent   | offsetHead 2 | offsetTail 6 | line   line 1 |
 | 
			
		||||
 | 
			
		||||
  it Nests a normal line under a preceding normal line
 | 
			
		||||
    key linedata:basic
 | 
			
		||||
    packages js
 | 
			
		||||
    input
 | 
			
		||||
      line 1
 | 
			
		||||
       line 2
 | 
			
		||||
    output
 | 
			
		||||
      level: 0 | head: line | tail: 1 | line: line 1
 | 
			
		||||
      level: 1 | head: line | tail: 2 | line: line 2
 | 
			
		||||
 it Handles a normal line at indent level 1 indented with tabs
 | 
			
		||||
  key linedata:tabs
 | 
			
		||||
  packages js python
 | 
			
		||||
  input
 | 
			
		||||
   \tline 1
 | 
			
		||||
  output
 | 
			
		||||
   | level 1 | indent \t | offsetHead 1 | offsetTail 5 | line \tline 1 |
 | 
			
		||||
 | 
			
		||||
 it Handles a normal line at indent level 2 indented with tabs
 | 
			
		||||
  key linedata:tabs
 | 
			
		||||
  packages js python
 | 
			
		||||
  input
 | 
			
		||||
   \t\tline 1
 | 
			
		||||
  output
 | 
			
		||||
   | level 2 | indent \t | offsetHead 2 | offsetTail 6 | line \t\tline 1 |
 | 
			
		||||
 | 
			
		||||
 it Nests a normal line under a preceding normal line
 | 
			
		||||
  key linedata:basic
 | 
			
		||||
  packages js python
 | 
			
		||||
  input
 | 
			
		||||
   line 1
 | 
			
		||||
    line 2
 | 
			
		||||
  output
 | 
			
		||||
   | level 0 | indent   | offsetHead 0 | offsetTail 4 | line line 1 |
 | 
			
		||||
   | level 1 | indent   | offsetHead 1 | offsetTail 5 | line  line 2 |
 | 
			
		||||
 | 
			
		||||
 it Nests multiple normal lines under a preceding normal line
 | 
			
		||||
  key linedata:basic
 | 
			
		||||
  packages js python
 | 
			
		||||
  input
 | 
			
		||||
   line 1
 | 
			
		||||
    line 2
 | 
			
		||||
    line 3
 | 
			
		||||
    line 4
 | 
			
		||||
  output
 | 
			
		||||
   | level 0 | indent   | offsetHead 0 | offsetTail 4 | line line 1 |
 | 
			
		||||
   | level 1 | indent   | offsetHead 1 | offsetTail 5 | line  line 2 |
 | 
			
		||||
   | level 1 | indent   | offsetHead 1 | offsetTail 5 | line  line 3 |
 | 
			
		||||
   | level 1 | indent   | offsetHead 1 | offsetTail 5 | line  line 4 |
 | 
			
		||||
 | 
			
		||||
 it Does not nest an empty line under a preceding normal line
 | 
			
		||||
  key linedata:basic
 | 
			
		||||
  packages js python
 | 
			
		||||
  comment Two newlines are needed here. A single newline will look to readline as if the input is finished.
 | 
			
		||||
  input line 1\n\n
 | 
			
		||||
  output
 | 
			
		||||
   | level 0 | indent   | offsetHead 0 | offsetTail 4 | line line 1 |
 | 
			
		||||
   | level 0 | indent   | offsetHead 0 | offsetTail 0 | line  |
 | 
			
		||||
 | 
			
		||||
 it Does not nest multiple empty lines under a preceding normal line
 | 
			
		||||
  key linedata:basic
 | 
			
		||||
  packages js python
 | 
			
		||||
  comment Four newlines are needed here. A single newline will look to readline as if the input is finished.
 | 
			
		||||
  input line 1\n\n\n\n
 | 
			
		||||
  output
 | 
			
		||||
   | level 0 | indent   | offsetHead 0 | offsetTail 4 | line line 1 |
 | 
			
		||||
   | level 0 | indent   | offsetHead 0 | offsetTail 0 | line  |
 | 
			
		||||
   | level 0 | indent   | offsetHead 0 | offsetTail 0 | line  |
 | 
			
		||||
   | level 0 | indent   | offsetHead 0 | offsetTail 0 | line  |
 | 
			
		||||
 | 
			
		||||
 it Handles head and tail matching for lines with head and tail
 | 
			
		||||
  key linedata:head-tail
 | 
			
		||||
  packages js python
 | 
			
		||||
  input
 | 
			
		||||
     head1 tail1 tail2 tail3
 | 
			
		||||
  output
 | 
			
		||||
   | head head1 | tail tail1 tail2 tail3 |
 | 
			
		||||
 | 
			
		||||
 it Handles head and tail matching for lines with head but no tail
 | 
			
		||||
  key linedata:head-tail
 | 
			
		||||
  packages js python
 | 
			
		||||
  input
 | 
			
		||||
     head1
 | 
			
		||||
  output
 | 
			
		||||
   | head head1 | tail  |
 | 
			
		||||
 | 
			
		||||
 it Handles head and tail matching for lines with head and trailing space
 | 
			
		||||
  key linedata:head-tail
 | 
			
		||||
  packages js python
 | 
			
		||||
  input   head1 \n
 | 
			
		||||
  output
 | 
			
		||||
   | head head1 | tail  |
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user