Skip to content

Commit

Permalink
Avoid test.cr in root of repo conflicting with parser warning specs (
Browse files Browse the repository at this point in the history
…#13259)

Co-authored-by: Quinton Miller <nicetas.c@gmail.com>
  • Loading branch information
Blacksmoke16 and HertzDevil authored Apr 4, 2023
1 parent 7f46589 commit 7b5a849
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions spec/compiler/parser/warnings_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require "../../support/syntax"

private def assert_parser_warning(source, message, *, file = __FILE__, line = __LINE__)
parser = Parser.new(source)
parser.filename = "test.cr"
parser.filename = "/test.cr"
parser.parse

warnings = parser.warnings.infos
Expand All @@ -12,7 +12,7 @@ end

private def assert_no_parser_warning(source, *, file = __FILE__, line = __LINE__)
parser = Parser.new(source)
parser.filename = "test.cr"
parser.filename = "/test.cr"
parser.parse

warnings = parser.warnings.infos
Expand All @@ -39,28 +39,28 @@ describe "Parser warnings" do

describe "warns on missing space before colon" do
it "in block param type restriction" do
assert_parser_warning("def foo(&block: Foo)\nend", "warning in test.cr:1\nWarning: space required before colon in type restriction (run `crystal tool format` to fix this)")
assert_parser_warning("def foo(&block: Foo)\nend", "warning in /test.cr:1\nWarning: space required before colon in type restriction (run `crystal tool format` to fix this)")
assert_no_parser_warning("def foo(&block : Foo)\nend")
assert_no_parser_warning("def foo(&@foo)\nend")
end

it "in anonymous block param type restriction" do
assert_parser_warning("def foo(&: Foo)\nend", "warning in test.cr:1\nWarning: space required before colon in type restriction (run `crystal tool format` to fix this)")
assert_parser_warning("def foo(&: Foo)\nend", "warning in /test.cr:1\nWarning: space required before colon in type restriction (run `crystal tool format` to fix this)")
assert_no_parser_warning("def foo(& : Foo)\nend")
assert_no_parser_warning("def foo(&)\nend")
end

it "in type declaration" do
assert_parser_warning("x: Int32", "warning in test.cr:1\nWarning: space required before colon in type declaration (run `crystal tool format` to fix this)")
assert_parser_warning("x: Int32", "warning in /test.cr:1\nWarning: space required before colon in type declaration (run `crystal tool format` to fix this)")
assert_no_parser_warning("x : Int32")
assert_parser_warning("class Foo\n@x: Int32\nend", "warning in test.cr:2\nWarning: space required before colon in type declaration (run `crystal tool format` to fix this)")
assert_parser_warning("class Foo\n@x: Int32\nend", "warning in /test.cr:2\nWarning: space required before colon in type declaration (run `crystal tool format` to fix this)")
assert_no_parser_warning("class Foo\n@x : Int32\nend")
assert_parser_warning("class Foo\n@@x: Int32\nend", "warning in test.cr:2\nWarning: space required before colon in type declaration (run `crystal tool format` to fix this)")
assert_parser_warning("class Foo\n@@x: Int32\nend", "warning in /test.cr:2\nWarning: space required before colon in type declaration (run `crystal tool format` to fix this)")
assert_no_parser_warning("class Foo\n@@x : Int32\nend")
end

it "in return type restriction" do
assert_parser_warning("def foo: Foo\nend", "warning in test.cr:1\nWarning: space required before colon in return type restriction (run `crystal tool format` to fix this)")
assert_parser_warning("def foo: Foo\nend", "warning in /test.cr:1\nWarning: space required before colon in return type restriction (run `crystal tool format` to fix this)")
assert_no_parser_warning("def foo : Foo\nend")
end
end
Expand Down

0 comments on commit 7b5a849

Please sign in to comment.