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

Fix destructure structs implementation #4

Merged
merged 3 commits into from
Dec 30, 2016

Conversation

muhifauzan
Copy link
Contributor

Resolves #2

@muhifauzan
Copy link
Contributor Author

@danielberkompas please have a look


describe "structs" do
test "can't match with different structs" do
refute d(%People{}) == %Person{}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be refute d(%People{}) = %Person{}?

Copy link
Contributor Author

@muhifauzan muhifauzan Dec 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, if we use assignment match, it will raise MatchError before refute evaluation takes action. Try using assert d(%People{}) == %Person{}, we will get the expected failure

1) test structs can't match with different structs (DestructureTest)
     test/destructure_test.exs:17
     Assertion with == failed
     code: d(%People{}) == %Person{}
     lhs:  %DestructureTest.People{people: nil}
     rhs:  %DestructureTest.Person{email: nil, name: nil}
     stacktrace:
       test/destructure_test.exs:18: (test)

Copy link
Contributor Author

@muhifauzan muhifauzan Dec 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or should I change it to use assert_raise? I guess it's more make sense to do it

@muhifauzan
Copy link
Contributor Author

muhifauzan commented Dec 30, 2016

@danielberkompas please have a look with the update

@danielberkompas
Copy link
Owner

Looks good to me, @muhifauzan!

@danielberkompas danielberkompas merged commit 58caf46 into danielberkompas:master Dec 30, 2016
@muhifauzan muhifauzan deleted the patch-0.2.1 branch June 17, 2017 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants