batavia icon indicating copy to clipboard operation
batavia copied to clipboard

Complete implementation of operations on standard types

Open freakboy3742 opened this issue 8 years ago • 151 comments

Javascript has a specific set of allowed operator and operations. Python has a set of operators and operations as well. However, the two don't match exactly. For example, Javascript behavior for adding/multiplying with Strings leads to behaviour that is quite distinct to the behavior provided by Python.

In order to replicate Python behavior in Javascript, Python's logic for all the basic operations needs to be implemented in the Batavia support library.

The test suite contains around 10000 tests in the that are currently marked as "expected failures". These reflect an attempt to do "every operation between every base data type". The task: pick a data type, and write the implementation of one of the math operation or comparison operators.

The tests will pass (and become unexpected successes) when the output of Python code doing that operation is the same when run through CPython and Batavia - and I mean byte-identical, down to the text and punctuation of the error message if appropriate.

If you want to see an example of what is involved, check out the implementation of add for integers. If you have an int, Python will allows you to add an int or a float to it; all other types raise a TypeError. The list of operations on int that still need to be implemented can be found here; if you add a new operation, delete the line that corresponds to that test, and the test will report as a pass, rather than an expected fail.

freakboy3742 avatar Apr 13 '16 09:04 freakboy3742

I will work on test_multiply_float for String

betojulio avatar May 06 '16 13:05 betojulio

I'm still working on test_add_bool for string

winza83 avatar May 08 '16 06:05 winza83

working on test_add_list

betojulio avatar May 09 '16 18:05 betojulio

working on test_add_none for string

betojulio avatar May 10 '16 12:05 betojulio

working on test_multiply_none for string

betojulio avatar May 11 '16 02:05 betojulio

working on test_unary_positive and test_unary_negative for string

betojulio avatar May 11 '16 18:05 betojulio

working on test_subtract_str for String

vyyyy avatar May 16 '16 13:05 vyyyy

Working on test_floor_divide_str for string

FlaviaBastos avatar May 18 '16 20:05 FlaviaBastos

Ops. I guess test_floor_divide_str got resolved by @wlmiller on issue #67 I will pick something else to work on.

FlaviaBastos avatar May 20 '16 16:05 FlaviaBastos

I'm sorry about that - I should have more carefully checked what was already being worked on.

For what it's worth, tackling these operations one at a time for each pair probably isn't the best way to go about it. For example, if you resolve test_floor_divide_str for string, you're very likely to also resolve floor_divide tests for many other combinations of types (in particular combinations which can't be floor_divided, e.g. string // tuple, list // dict, etc.).

In #67 I set out to implement the abs builtin and ended up resolving a ton of other tests along the way, including dozens of the tests in datatypes.

A more natural division is by operation. For example, resolving all of the floor_divide tests where both types have been implemented is a very reasonable chunk to work on. You could divide it further - e.g. floor_divide where both sides are numbers or floor_divide for combinations that will result in TypeErrors. Anything smaller than that is probably a pretty unnatural way to split things up.

wlmiller avatar May 20 '16 19:05 wlmiller

No worries! I saw your implementation and there's no way I could have accomplished that. :sweat_smile: Good job!

FlaviaBastos avatar May 20 '16 19:05 FlaviaBastos

working on test_setattr for string

tfors avatar Jun 02 '16 17:06 tfors

I'm working on test_add_bool in in place string operations.

mauritt avatar Jun 02 '16 17:06 mauritt

I'm working on test_add_tuple in in-place string operations.

mauritt avatar Jun 02 '16 19:06 mauritt

Working on test_add_dict in in-place string operations.

mauritt avatar Jun 02 '16 19:06 mauritt

Working on test_add_float in in-place string operations.

mauritt avatar Jun 02 '16 19:06 mauritt

working on test_true_divide_bool

netoxico avatar Jun 02 '16 19:06 netoxico

working on in-place additions to strings

mauritt avatar Jun 02 '16 21:06 mauritt

working on test_add_int

mbrownGraham avatar Jun 02 '16 22:06 mbrownGraham

working on test_pow_str

ghost avatar Jun 02 '16 23:06 ghost

working on test_multiply_bool

bellisk avatar Jun 03 '16 00:06 bellisk

working on Str inplace xor

tfors avatar Jun 03 '16 01:06 tfors

Working on str in-place addition to str (test_add_str in InplaceStrOperationTests)

mauritt avatar Jun 03 '16 15:06 mauritt

Working on 'test_add_set' in InplaceStrOperationTests

mauritt avatar Jun 03 '16 15:06 mauritt

Working on Int inplace multiply

tfors avatar Jun 03 '16 15:06 tfors

Working on InplaceStrOperationTests test_modulo_none (and any other string modulo operations that throw the SyntaxError: can't assign to literal error; update: looks like all of them)

aedunn6 avatar Jun 03 '16 16:06 aedunn6

Working on batavia.type_name in Type.js. I'm extending it so that bytes, sets, etc return the correct name and not "Native Type"

mauritt avatar Jun 03 '16 16:06 mauritt

Working on implementing batavia.builtins.set in order to get InplaceStrOperationTests test_modulo_set to work

aedunn6 avatar Jun 03 '16 19:06 aedunn6

working on String.prototype._ie_

raehart avatar Jun 04 '16 19:06 raehart

According to slack, int.__lt__ is now being worked on.

phildini avatar Jun 04 '16 19:06 phildini