Multi-line String Test Specifications
Test cases for multi-line string literals with triple quotes and indentation handling.
Test Case: MULTILINE_001 - Triple Double Quotes
Purpose
Test parsing of triple double-quoted strings.
Input
"""Hello World"""
Expected Result
- Token type: String
- Value: "Hello World"
Test Case: MULTILINE_002 - Triple Single Quotes
Purpose
Test parsing of triple single-quoted strings.
Input
'''Hello World'''
Expected Result
- Token type: String
- Value: "Hello World"
Test Case: MULTILINE_003 - Basic Multi-line String
Purpose
Test basic multi-line string with multiple lines.
Input
"""
Line 1
Line 2
Line 3
"""
Expected Result
- Token type: String
- Value: "Line 1\nLine 2\nLine 3"
- Line breaks preserved
Test Case: MULTILINE_004 - Indentation Processing
Purpose
Test that common indentation is removed correctly.
Input
"""
function greet(name) {
console.log(`Hello, ${name}!`);
if (name === 'World') {
console.log('Welcome to TON!');
}
}
"""
Expected Result
function greet(name) {
console.log(`Hello, ${name}!`);
if (name === 'World') {
console.log('Welcome to TON!');
}
}
Common leading indentation (8 spaces) removed from all lines.
Test Case: MULTILINE_005 - Preserve Empty Lines
Purpose
Test that empty lines are preserved in multi-line strings.
Input
"""
Line 1
Line 3
Line 5
"""
Expected Result
Line 1
Line 3
Line 5
Empty lines preserved, common indentation removed.
Test Case: MULTILINE_006 - Mixed Indentation Levels
Purpose
Test handling of mixed indentation levels.
Input
"""
API Documentation
Overview:
This API provides user management functionality.
Key features:
• User creation and management
• Authentication and authorization
Usage:
POST /api/users
GET /api/users/{id}
"""
Expected Result
API Documentation
Overview:
This API provides user management functionality.
Key features:
• User creation and management
• Authentication and authorization
Usage:
POST /api/users
GET /api/users/{id}
Common indentation (4 spaces) removed, relative indentation preserved.
Test Case: MULTILINE_007 - Escape Sequences
Purpose
Test escape sequence processing in multi-line strings.
Input
"""
Line 1
Line 2 with \t explicit tab
Line 3 with \"escaped quotes\"
Line 4 with \\ backslash
Unicode: \u0041\u0042\u0043
"""
Expected Result
Line 1
Line 2 with explicit tab
Line 3 with "escaped quotes"
Line 4 with \ backslash
Unicode: ABC
Escape sequences processed correctly.
Test Case: MULTILINE_008 - Inline Multi-line String
Purpose
Test multi-line string syntax used on a single line.
Input
"""This is all on one line"""
Expected Result
- Token type: String
- Value: "This is all on one line"
Test Case: MULTILINE_009 - Content Starting on Opening Line
Purpose
Test when content starts on the same line as opening quotes.
Input
"""This starts here
and continues here
"""
Expected Result
This starts here
and continues here
Content preserved from first line.
Test Case: MULTILINE_010 - Special Characters
Purpose
Test special characters in multi-line strings.
Input
"""
Special chars: !@#$%^&*()
Quotes: 'single' and "double"
Brackets: {}, [], ()
Math: 1 + 2 = 3
"""
Expected Result
Special chars: !@#$%^&*()
Quotes: 'single' and "double"
Brackets: {}, [], ()
Math: 1 + 2 = 3
All special characters preserved literally.
Test Case: MULTILINE_011 - Tab Indentation
Purpose
Test handling of tab characters in indentation.
Input (tabs shown as [TAB])
"""
[TAB][TAB]Line with tabs
[TAB][TAB]Another tabbed line
[TAB][TAB][TAB]More indented
"""
Expected Result
Line with tabs
Another tabbed line
[TAB]More indented
Common tab indentation removed, relative preserved.
Test Case: MULTILINE_012 - Trailing Whitespace
Purpose
Test preservation of trailing whitespace on lines.
Input (spaces shown as ·)
"""
Line 1···
Line 2
Line 3··
"""
Expected Result
Trailing spaces preserved on each line.
Implementation Notes
- Indentation detection should find minimum common indentation
- Empty lines don't affect indentation calculation
- Tabs and spaces should not be mixed in indentation
- Line endings normalized to \n internally
- Content can start on opening line or next line
- Closing quotes can be on same line as content or separate
Edge Cases
- Empty multi-line string:
""""""
- Single line with newline:
"""\n"""
- Windows line endings (\r\n)
- Mac line endings (\r)
- Mixed line endings in same string
- Very long lines (>1000 characters)
- Deeply indented content (>100 spaces)