Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid test.cr in root of repo conflicting with parser warning specs #13259

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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