Skip to content

Commit

Permalink
Record constructors bacame to take only keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed Oct 23, 2017
1 parent 8d36461 commit f268771
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def fx_record_type():

@fixture
def fx_point(fx_record_type, fx_unboxed_type):
return fx_record_type(fx_unboxed_type(3.14), fx_unboxed_type(1.592))
return fx_record_type(left=fx_unboxed_type(3.14),
top=fx_unboxed_type(1.592))


@fixture
Expand All @@ -35,7 +36,7 @@ def fx_rectangle_type():

@fixture
def fx_rectangle(fx_rectangle_type, fx_point):
return fx_rectangle_type(fx_point, fx_point)
return fx_rectangle_type(upper_left=fx_point, lower_right=fx_point)


@fixture
Expand Down
14 changes: 8 additions & 6 deletions tests/serialize_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ def test_serialize_record_type(fx_point):

def test_serialize_union_type(fx_point, fx_offset, fx_circle_type,
fx_rectangle_type):
circle = fx_circle_type(fx_point, fx_offset)
circle = fx_circle_type(origin=fx_point, radius=fx_offset)
s = {
'_type': 'shape', '_tag': 'circle',
'origin': serialize_record_type(fx_point),
'radius': serialize_unboxed_type(fx_offset)
}
assert serialize_union_type(circle) == s
rectangle = fx_rectangle_type(fx_point, fx_point)
rectangle = fx_rectangle_type(upper_left=fx_point, lower_right=fx_point)
s = {
'_type': 'shape', '_tag': 'rectangle',
'upper_left': serialize_record_type(fx_point),
Expand Down Expand Up @@ -93,8 +93,9 @@ def test_serialize_meta_set(d, expect):


def test_serialize_meta_list(fx_record_type, fx_unboxed_type, fx_offset):
record = fx_record_type(fx_offset, fx_offset)
record2 = fx_record_type(fx_unboxed_type(1.1), fx_unboxed_type(1.2))
record = fx_record_type(left=fx_offset, top=fx_offset)
record2 = fx_record_type(left=fx_unboxed_type(1.1),
top=fx_unboxed_type(1.2))
serialize_result = serialize_meta([record, record2])
assert serialize_result == [
{'_type': 'point', 'x': 1.2, 'top': 1.2},
Expand All @@ -105,8 +106,9 @@ def test_serialize_meta_list(fx_record_type, fx_unboxed_type, fx_offset):

def test_serialize_meta_set_of_record(fx_record_type, fx_unboxed_type,
fx_offset):
record = fx_record_type(fx_offset, fx_offset)
record2 = fx_record_type(fx_unboxed_type(1.1), fx_unboxed_type(1.2))
record = fx_record_type(left=fx_offset, top=fx_offset)
record2 = fx_record_type(left=fx_unboxed_type(1.1),
top=fx_unboxed_type(1.2))
serialize_result = serialize_meta({record, record2})
assert record.__nirum_serialize__() in serialize_result
assert record2.__nirum_serialize__() in serialize_result
Expand Down

0 comments on commit f268771

Please sign in to comment.