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

Problem in macro expansion for be_between #5

Closed
davidepaolotua opened this issue Feb 21, 2020 · 2 comments
Closed

Problem in macro expansion for be_between #5

davidepaolotua opened this issue Feb 21, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@davidepaolotua
Copy link

Hi all, just a small problem in the matcher with crystal 0.33...
Given this file test_problem.cr

require "spectator"
Spectator.describe "A test" do
  it "should work" do
    expect(7).to be_between(1, 10)
  end
end

I get this:

crystal spec ./test_problem.cr
There was a problem expanding macro 'be_between'

Code in test_problem.cr:4:18

 4 | expect(7).to be_between(1, 10)
                  ^
Called macro defined in lib/spectator/src/spectator/dsl/matchers.cr:344:5

 344 | macro be_between(min, max)

Which expanded to:

 > 1 | __temp_1031 = Range.new(1, 10))
                                     ^
Error: unexpected token: )

Running with --error-trace gives this trace:

In test_problem.cr:3:3

 3 | it "should work" do
     ^
Error: expanding macro


There was a problem expanding macro 'it'

Called macro defined in lib/spectator/src/spectator/dsl/examples.cr:6:5

 6 | macro it(description = nil, _source_file = __FILE__, _source_line = __LINE__, &block)

Which expanded to:

 >  1 |
 >  2 |         def __temp_35
 >  3 |           (expect(7)).to(be_between(1, 10))
 >  4 |         end
 >  5 |
 >  6 |
 >  7 |       __temp_36 = ::Spectator::Source.new("/Users/tuad/work/slack/voronoi_stuff/crystal_voro/voronoi_geometry/test_problem.cr", 3)
 >  8 |       ::Spectator::SpecBuilder.add_example(
 >  9 |         "should work",
 > 10 |         __temp_36,
 > 11 |         SpectatorTest::Context__temp_33
 > 12 |       ) { |test| test.as(SpectatorTest::Context__temp_33).__temp_35 }
 > 13 |
Error: instantiating 'SpectatorTest::Context__temp_33#__temp_35()'


There was a problem expanding macro 'be_between'

Called macro defined in lib/spectator/src/spectator/dsl/matchers.cr:344:5

 344 | macro be_between(min, max)

Which expanded to:

 > 1 |       __temp_1031 = Range.new(1, 10))
 > 2 |       __temp_1032 = ["1", "10"].join(" to ")
 > 3 |       __temp_1033 = ::Spectator::TestValue.new(__temp_1031, __temp_1032)
 > 4 |       :Spectator::Matchers::RangeMatcher.new(__temp_1033)
 > 5 |
Error: unexpected token: )
@davidepaolotua
Copy link
Author

Ok, opened a MR for that on glab :)

@icy-arctic-fox icy-arctic-fox added the bug Something isn't working label Feb 21, 2020
@icy-arctic-fox
Copy link
Owner

Thank you for the detailed information! Looks like there is a hard to spot extra paren in there. I'll take a look at your MR and we can get this fixed 😄

icy-arctic-fox added a commit that referenced this issue Feb 21, 2020
Fixed GitHub Issue #5 - Thanks @jinn999
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants