voc
voc copied to clipboard
Complete implementation of operations on standard types
Java 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, Java will allow any object to be added to a java.lang.String
; Python does not. On the other hand, Python allows multiplication of str
by int
(producing a duplicated string); Java does not.
In order to replicate Python behavior in Java, Python's logic for all the basic operations needs to be implemented in the VOC Java support library.
The test suite contains around 2800 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 dunder operation (e.g., __add__
or __xor__
) or comparison (__lt__
or __eq__
) methods.
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 VOC - 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.
When you submit a PR for this, prefix the PR message with "Refs #36", so it will be associated with this ticket.
Folks, I'm picking up the test_unary_positive
test in tests/test_str.py
. Please don't work on it so that we can avoid collisions! :smile:
I forgot to mention, I'll be doing all the unary operator tests for String. Please stay away -- they're mine! :stuck_out_tongue_closed_eyes:
Hello, people. I'll be picking up the following tests for string types:
'test_eq_bytearray',
'test_eq_bytes',
'test_eq_class',
'test_eq_complex',
'test_eq_frozenset',
I'm working through the Int class' unary and binary operations.
Hi! I'm working on the data type Boolean, starting with comparison methods.
I'm working through the List class
I'm working through the Tuple class
Hello, I'll be picking up the byte class.
Hello I am working on Int class (power and xor)
I'm working on next builtin.
~~I'm going to work on multiplying some data structures (test_multiply_*
), starting with str, float, and list~~
Instead working on fleshing out the Set class with operations and compator errors
I'm attempting InplaceStrOperationTests 'test_add_int'
I'm now attempting BinaryStrOperationTests 'test_subscr_class' SCRATCH that -- having issues and terminating for now. Please feel free to fix this class if you wish.
Please reserve float
for me until Sunday, June 5th.
All my background in integer binary calculations is stale. It seems like the int / shift functions might be a good place to start, but are there handy docs online with the specs for binary math done by java? ty! Anne via PyGotham curiosity about PyBee coins and great lecture on Python for Android/iOS.
@AnneTheAgile Most of the operations for int have been implemented, except for those related to types that aren't fully defined (complex, bytearray, etc). There's a couple missing (or buggy) for floor divide, true divide and inline multiplication.
You can see the operations that are "missing" by looking at a test file (like ( https://github.com/pybee/voc/blob/master/tests/datatypes/test_int.py)[this one]) - any entry in the "not_implemented" section indicates an operator that isn't implemented (or isn't correctly implemented) for a given data type pair.
If you find me at the conference, I'm happy to give you some in-person pointers. I might even give you a coin in advance, if you promise you'll keep going until you get a commit :-)
Going to try the str inline right shift operator
nevermind. Already done in vox. Trying float_eq_list
Trying float_ne_list
Working on test_list.InplaceListOperationTests.test_add_tuple
.
Working on test_list.test_subtract_slice
.
Looking at BinaryStrOperationTests.test_modulo_bool
Not working on this any more. It's up for grabs
Looking at test_bytes
and the Bytes type
I'll be working on set
's behaviour.
I'm now looking at InplaceListOperationTests: test_multiply_list test_multiply_int test_multiply_bool
This is looking good: OK (expected failures=42)
Looking at iadd for bytes on a List
Bytes is pretty much done. I can also do ByteArray since that's a clone of Bytes.
I'll handle the missing multiply operations:
- ~~test_multiply_bytearray~~
- ~~test_multiply_bytes~~
- test_multiply_class (depends on Type implementation)
- test_multiply_complex
- test_multiply_frozenset
i'm working on Bool multiply bytes... test_multiply_bytes test_multiply_bytearray