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

Defaulting None for optional fields #165

Merged
merged 5 commits into from
Aug 16, 2017
Merged

Conversation

earlbread
Copy link
Contributor

@earlbread earlbread commented Aug 14, 2017

This fixes #70.

Copy link
Member

@dahlia dahlia left a comment

Choose a reason for hiding this comment

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

@earlbread Generally it looks good to me. 👍 We have only few things to fix.

int64? price,
bool sale,
uri? url,
);
Copy link
Member

Choose a reason for hiding this comment

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

We should test union tags as well e.g.:

union union-test = tag-a
                 | tag-b (text a, text? b, int64 c, int64 d?);

def test_optional_initializer_test():
product = Product(name=u'coffee', sale=False)
assert product.price is None
assert product.url is None
Copy link
Member

Choose a reason for hiding this comment

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

We should test union tags as well e.g.:

def test_union_tags_optional_initializer():
    t = TagB(a=u'test', c=123)
    assert t.a == u'test'
    assert t.b is None
    assert t.c == 123
    assert t.d is None

@@ -249,3 +249,9 @@ def test_service():
PingService().ping(nonce=u'nonce')
with raises(TypeError):
PingService().ping(wrongkwd=u'a')


def test_optional_initializer_test():
Copy link
Member

Choose a reason for hiding this comment

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

Since the function name already starts with test_ we need no _test suffix here.

@dahlia dahlia added the typ:enhance Type: Enhancement/new feature label Aug 15, 2017
@earlbread
Copy link
Contributor Author

earlbread commented Aug 16, 2017

@dahlia I fixed things you mentioned. Thank you!

Copy link
Member

@dahlia dahlia left a comment

Choose a reason for hiding this comment

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

Everything looks good to me. 👍

@dahlia dahlia merged commit 97a2e6a into nirum-lang:master Aug 16, 2017
@dahlia dahlia added the cmp:compiler Component: Compiler backend (e.g., annotation processors, code generators) label Aug 26, 2017
dahlia added a commit to nirum-lang/nirum-python that referenced this pull request Oct 23, 2017
@earlbread earlbread deleted the issue70 branch May 6, 2018 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmp:compiler Component: Compiler backend (e.g., annotation processors, code generators) typ:enhance Type: Enhancement/new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants