Skip to content

Commit

Permalink
Merge branch 'master' into feature/llvm-18-operand-bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil authored Dec 14, 2023
2 parents 0a29b2b + 0b251d4 commit ec10df6
Show file tree
Hide file tree
Showing 33 changed files with 9,080 additions and 151 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/llvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
llvm_ubuntu_version: "18.04"
- llvm_version: "16.0.3"
llvm_ubuntu_version: "22.04"
- llvm_version: "17.0.2"
- llvm_version: "17.0.6"
llvm_ubuntu_version: "22.04"
name: "LLVM ${{ matrix.llvm_version }}"
steps:
Expand Down
20 changes: 10 additions & 10 deletions spec/compiler/crystal/tools/doc/method_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ describe Doc::Method do

describe "doc" do
it "gets doc from underlying method" do
program = semantic("
program = top_level_semantic(<<-CRYSTAL, wants_doc: true).program
class Foo
# Some docs
def foo
end
end
", wants_doc: true).program
CRYSTAL
generator = Doc::Generator.new program, [""]
method = generator.type(program.types["Foo"]).lookup_method("foo").not_nil!
method.doc.should eq("Some docs")
Expand Down Expand Up @@ -181,7 +181,7 @@ describe Doc::Method do
end

it "inherits doc from ancestor (no extra comment)" do
program = semantic("
program = top_level_semantic(<<-CRYSTAL, wants_doc: true).program
class Foo
# Some docs
def foo
Expand All @@ -193,15 +193,15 @@ describe Doc::Method do
super
end
end
", wants_doc: true).program
CRYSTAL
generator = Doc::Generator.new program, [""]
method = generator.type(program.types["Bar"]).lookup_method("foo").not_nil!
method.doc.should eq("Some docs")
method.doc_copied_from.should eq(generator.type(program.types["Foo"]))
end

it "inherits doc from previous def (no extra comment)" do
program = semantic("
program = top_level_semantic(<<-CRYSTAL, wants_doc: true).program
class Foo
# Some docs
def foo
Expand All @@ -211,15 +211,15 @@ describe Doc::Method do
previous_def
end
end
", wants_doc: true).program
CRYSTAL
generator = Doc::Generator.new program, [""]
method = generator.type(program.types["Foo"]).lookup_method("foo").not_nil!
method.doc.should eq("Some docs")
method.doc_copied_from.should be_nil
end

it "inherits doc from ancestor (use :inherit:)" do
program = semantic("
program = top_level_semantic(<<-CRYSTAL, wants_doc: true).program
class Foo
# Some docs
def foo
Expand All @@ -232,15 +232,15 @@ describe Doc::Method do
super
end
end
", wants_doc: true).program
CRYSTAL
generator = Doc::Generator.new program, [""]
method = generator.type(program.types["Bar"]).lookup_method("foo").not_nil!
method.doc.should eq("Some docs")
method.doc_copied_from.should be_nil
end

it "inherits doc from ancestor (use :inherit: plus more content)" do
program = semantic("
program = top_level_semantic(<<-CRYSTAL, wants_doc: true).program
class Foo
# Some docs
def foo
Expand All @@ -257,7 +257,7 @@ describe Doc::Method do
super
end
end
", wants_doc: true).program
CRYSTAL
generator = Doc::Generator.new program, [""]
method = generator.type(program.types["Bar"]).lookup_method("foo").not_nil!
method.doc.should eq("Before\n\nSome docs\n\nAfter")
Expand Down
12 changes: 4 additions & 8 deletions spec/compiler/crystal/tools/doc/type_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require "../../../spec_helper"

describe Doc::Type do
it "doesn't show types for alias type" do
result = semantic(%(
program = top_level_semantic(<<-CRYSTAL, wants_doc: true).program
class Foo
class Bar
end
Expand All @@ -11,9 +11,7 @@ describe Doc::Type do
alias Alias = Foo
Alias
))

program = result.program
CRYSTAL

# Set locations to types relative to the included dir
# so they are included by the doc generator
Expand All @@ -30,14 +28,12 @@ describe Doc::Type do
end

it "finds construct when searching class method (#8095)" do
result = semantic(%(
program = top_level_semantic(<<-CRYSTAL, wants_doc: true).program
class Foo
def initialize(x)
end
end
))

program = result.program
CRYSTAL

generator = Doc::Generator.new program, [""]
foo = generator.type(program.types["Foo"])
Expand Down
223 changes: 222 additions & 1 deletion spec/compiler/formatter/formatter_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private def assert_format(input, output = input, strict = false, flags = nil, fi
end

# Check idempotency
result2 = Crystal.format(result)
result2 = Crystal.format(result, flags: flags)
unless result == result2
fail "Idempotency failed:\nBefore: #{result.inspect}\nAfter: #{result2.inspect}", file: file, line: line
end
Expand Down Expand Up @@ -886,6 +886,227 @@ describe Crystal::Formatter do
CRYSTAL
end

context "adds trailing comma to def multi-line normal, splat, and double splat parameters" do
assert_format <<-CRYSTAL, <<-CRYSTAL, flags: %w[def_trailing_comma]
macro foo(
a,
b
)
end
CRYSTAL
macro foo(
a,
b,
)
end
CRYSTAL

assert_format <<-CRYSTAL, <<-CRYSTAL, flags: %w[def_trailing_comma]
macro foo(
a,
*b
)
end
CRYSTAL
macro foo(
a,
*b,
)
end
CRYSTAL

assert_format <<-CRYSTAL, <<-CRYSTAL, flags: %w[def_trailing_comma]
fun foo(
a : Int32,
b : Int32
)
end
CRYSTAL
fun foo(
a : Int32,
b : Int32,
)
end
CRYSTAL

assert_format <<-CRYSTAL, flags: %w[def_trailing_comma]
fun foo(
a : Int32,
...
)
end
CRYSTAL

assert_format <<-CRYSTAL, <<-CRYSTAL, flags: %w[def_trailing_comma]
def foo(
a,
b
)
end
CRYSTAL
def foo(
a,
b,
)
end
CRYSTAL

assert_format <<-CRYSTAL, <<-CRYSTAL, flags: %w[def_trailing_comma]
def foo(
a : Int32,
b : Int32
)
end
CRYSTAL
def foo(
a : Int32,
b : Int32,
)
end
CRYSTAL

assert_format <<-CRYSTAL, <<-CRYSTAL, flags: %w[def_trailing_comma]
def foo(
a : Int32,
b : Int32 = 1
)
end
CRYSTAL
def foo(
a : Int32,
b : Int32 = 1,
)
end
CRYSTAL

assert_format <<-CRYSTAL, <<-CRYSTAL, flags: %w[def_trailing_comma]
def foo(
a,
b c
)
end
CRYSTAL
def foo(
a,
b c,
)
end
CRYSTAL

assert_format <<-CRYSTAL, <<-CRYSTAL, flags: %w[def_trailing_comma]
def foo(
a,
@[Ann] b
)
end
CRYSTAL
def foo(
a,
@[Ann] b,
)
end
CRYSTAL

assert_format <<-CRYSTAL, <<-CRYSTAL, flags: %w[def_trailing_comma]
def foo(
a,
@[Ann]
b
)
end
CRYSTAL
def foo(
a,
@[Ann]
b,
)
end
CRYSTAL

assert_format <<-CRYSTAL, <<-CRYSTAL, flags: %w[def_trailing_comma]
def foo(
a, b
)
end
CRYSTAL
def foo(
a, b,
)
end
CRYSTAL

assert_format <<-CRYSTAL, <<-CRYSTAL, flags: %w[def_trailing_comma]
def foo(
a, b,
c, d
)
end
CRYSTAL
def foo(
a, b,
c, d,
)
end
CRYSTAL

assert_format <<-CRYSTAL, <<-CRYSTAL, flags: %w[def_trailing_comma]
def foo(
a, # Foo
b # Bar
)
end
CRYSTAL
def foo(
a, # Foo
b, # Bar
)
end
CRYSTAL

assert_format <<-CRYSTAL, <<-CRYSTAL, flags: %w[def_trailing_comma]
def foo(
a,
*b
)
end
CRYSTAL
def foo(
a,
*b,
)
end
CRYSTAL

assert_format <<-CRYSTAL, <<-CRYSTAL, flags: %w[def_trailing_comma]
def foo(
a,
**b
)
end
CRYSTAL
def foo(
a,
**b,
)
end
CRYSTAL

assert_format <<-CRYSTAL, flags: %w[def_trailing_comma]
def foo(
a,
&block
)
end
CRYSTAL

assert_format <<-CRYSTAL, flags: %w[def_trailing_comma]
def foo(
a,
)
end
CRYSTAL
end

assert_format "1 + 2", "1 + 2"
assert_format "1 &+ 2", "1 &+ 2"
assert_format "1 > 2", "1 > 2"
Expand Down
Loading

0 comments on commit ec10df6

Please sign in to comment.