Skip to content

Commit

Permalink
Add tests for alternate newline character
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Jun 17, 2024
1 parent 2a43dae commit 1989946
Show file tree
Hide file tree
Showing 5 changed files with 218 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ crates/ruff_linter/resources/test/fixtures/pycodestyle/W391_3.py text eol=crlf
crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring_code_examples_crlf.py text eol=crlf
crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples_crlf.py.snap text eol=crlf

crates/ruff_python_parser/resources/invalid/re_lex_logical_token_windows_eol.py text eol=crlf
crates/ruff_python_parser/resources/invalid/re_lex_logical_token_mac_eol.py text eol=cr

crates/ruff_python_parser/resources/inline linguist-generated=true

ruff.schema.json linguist-generated=true text=auto eol=lf
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
if call(foo, [a, b def bar(): pass
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if call(foo, [a, b
def bar():
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
source: crates/ruff_python_parser/tests/fixtures.rs
input_file: crates/ruff_python_parser/resources/invalid/re_lex_logical_token_mac_eol.py
---
## AST

```
Module(
ModModule {
range: 0..46,
body: [
If(
StmtIf {
range: 0..46,
test: Call(
ExprCall {
range: 3..19,
func: Name(
ExprName {
range: 3..7,
id: "call",
ctx: Load,
},
),
arguments: Arguments {
range: 7..19,
args: [
Name(
ExprName {
range: 8..11,
id: "foo",
ctx: Load,
},
),
List(
ExprList {
range: 13..18,
elts: [
Name(
ExprName {
range: 14..15,
id: "a",
ctx: Load,
},
),
Name(
ExprName {
range: 17..18,
id: "b",
ctx: Load,
},
),
],
ctx: Load,
},
),
],
keywords: [],
},
},
),
body: [
FunctionDef(
StmtFunctionDef {
range: 23..46,
is_async: false,
decorator_list: [],
name: Identifier {
id: "bar",
range: 27..30,
},
type_params: None,
parameters: Parameters {
range: 30..32,
posonlyargs: [],
args: [],
vararg: None,
kwonlyargs: [],
kwarg: None,
},
returns: None,
body: [
Pass(
StmtPass {
range: 42..46,
},
),
],
},
),
],
elif_else_clauses: [],
},
),
],
},
)
```
## Errors

|
1 | if call(foo, [a, b def bar(): pass
| Syntax Error: Expected ']', found NonLogicalNewline
|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
source: crates/ruff_python_parser/tests/fixtures.rs
input_file: crates/ruff_python_parser/resources/invalid/re_lex_logical_token_windows_eol.py
---
## AST

```
Module(
ModModule {
range: 0..50,
body: [
If(
StmtIf {
range: 0..48,
test: Call(
ExprCall {
range: 3..20,
func: Name(
ExprName {
range: 3..7,
id: "call",
ctx: Load,
},
),
arguments: Arguments {
range: 7..20,
args: [
Name(
ExprName {
range: 8..11,
id: "foo",
ctx: Load,
},
),
List(
ExprList {
range: 13..18,
elts: [
Name(
ExprName {
range: 14..15,
id: "a",
ctx: Load,
},
),
Name(
ExprName {
range: 17..18,
id: "b",
ctx: Load,
},
),
],
ctx: Load,
},
),
],
keywords: [],
},
},
),
body: [
FunctionDef(
StmtFunctionDef {
range: 24..48,
is_async: false,
decorator_list: [],
name: Identifier {
id: "bar",
range: 28..31,
},
type_params: None,
parameters: Parameters {
range: 31..33,
posonlyargs: [],
args: [],
vararg: None,
kwonlyargs: [],
kwarg: None,
},
returns: None,
body: [
Pass(
StmtPass {
range: 44..48,
},
),
],
},
),
],
elif_else_clauses: [],
},
),
],
},
)
```
## Errors

|
1 | if call(foo, [a, b
| ___________________^
2 | | def bar():
| |_^ Syntax Error: Expected ']', found NonLogicalNewline
3 | pass
|

0 comments on commit 1989946

Please sign in to comment.