xpenatan/gdx-teavm

Need port gdx test

nicolaichuk opened this issue · 1 comments

Will be very good if you port gdx-test https://github.com/libgdx/libgdx/tree/master/gdx/test/com/badlogic/gdx to test-engine for web dragome.

And check that all test run ok.

I think that perhaps will be trouble with Bits.java because it used bitwise operations with long that do not have full support in javascript.

Bitwise operations are a bit of a hack in Javascript. Since all numbers in Javascript are floating point, and bitwise operators only work on integers, Javascript does a little behind the scenes magic to make it appear bitwise operations are being applied to a 32bit signed integer.

Specifically, Javascript takes the number you are working on and takes the integer portion of the number. It then converts the integer to the most number of bits that number represents, up to 31 bits (1 bit for the sign). So 0 would create a two bit number (1 for the sign, and 1 bit for 0), likewise 1 would create two bits. 2 would create a 3 bit number, 4 would create a 4 bit number, etc…

It's important to realize that you're not guaranteed a 32bit number, for instance running not on zero should, in theory, convert 0 to 4,294,967,295, instead it will return -1 for two reasons, the first being that all numbers are signed in Javascript so "not" always reverses the sign, and second Javascript couldn't make more than one bit from the number zero and not zero becomes one. Therefore ~0=-1.

So bitwise signs in Javascript are up to 32 bits.

https://stackoverflow.com/questions/3081271/number-of-bits-to-represent-a-number

Some tests is already at https://github.com/xpenatan/gdx-dragome-backend/tree/master/tests/gdx-tests-dragome/src/com/badlogic/gdx/tests

I could delete the ones here and make it target the core gdx tests.