-
Couldn't load subscription status.
- Fork 11
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably a good idea to get @lrhn to review the test changes, since he wrote the tests in the first place.
| @@ -1,5 +1,5 @@ | |||
| name: typed_data | |||
| version: 1.1.5 | |||
| version: 1.1.6 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this doesn't change any user-consumable code, can we just make it 1.1.6-dev?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bumped version and updated sdk constraints. does this look ok?
test/typed_buffers_test.dart
Outdated
| 0x7aaaaaaaaaaaaaaa, | ||
| 0x7000000000000001, | ||
| 0x7000000000000000, | ||
| 0x7fffffffffffffff, //2^63 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this 2^63 - 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, it is.
test/typed_buffers_test.dart
Outdated
| expect(buffer.contains(min - 1), isFalse); | ||
| expect(buffer.contains(max + 1), isFalse); | ||
| // for signed 64 bit ints, min and max wrap around. min-1=max and max+1=min | ||
| if (bits == 64){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: ) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, had to do without the formatter.
test/typed_buffers_test.dart
Outdated
| // Both values are in `samples`, but equality is performed without rounding. | ||
| expect(buffer.contains(min - 1), isFalse); | ||
| expect(buffer.contains(max + 1), isFalse); | ||
| // for signed 64 bit ints, min and max wrap around. min-1=max and max+1=min |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Capitalization, punctuation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
| 0x0ffffffffffffffff, | ||
| 0xaaaaaaaaaaaaaaaa, | ||
| 0x8000000000000001, | ||
| 0x8000000000000000, // 2^63 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider keeping 0x8000000000000000 value if possible, as it is a corner case which is worth checking.
With the new fixed-size wrap-around integers, 0x8000000000000000 == -0x8000000000000000 == min.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works, added back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving from a style perspective.
CHANGELOG.md
Outdated
| @@ -1,3 +1,7 @@ | |||
| ## 1.1.6 | |||
|
|
|||
| * Fix tests to work with Dart 2.0 fixed size ints. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also remove this changelog entry now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| 0x10000000000000000, // 2^64 | ||
| 0x0ffffffffffffffff, | ||
| 0xaaaaaaaaaaaaaaaa, | ||
| 0x8000000000000001, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 16-digit hex numerals (that is, all but the first two numerals) are all valid Dart 2 integer literals.
Hex literals are allowed to have values in the range -2^63 .. 2^64-1, with the upper ones being normalized to negative values. This allows you to write bit patterns efficiently.
So, only remove the first two, 0x10000000000000001 and 0x10000000000000000.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
test/typed_buffers_test.dart
Outdated
| // as signed ints. | ||
| expect(buffer.contains(min - 1), isTrue); | ||
| } else { | ||
| expect(buffer.contains(min - 1), isFalse); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see no reason these tests can't run on 64-bit values too.
The min and max values might not really be min and max (they're 0 and -1 when represented as Int64), but the Uint64List.contains method will still do int.== to figure out if the argument is in the list, and max + 1 is 0, and that's definitely in the list.
So, all in all, I don't see a problem with keeping the test as-is (but maybe commenting that Uint64List acts exactly like Int64List because the int type cannot distinguish them.
The Uint64List tests will not work on JavaScript anyway because Uint64List doesn't exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Uint64
min is 0, min-1 = -1
max is -1, max+1 = 0
and for Int64
min is -9223372036854775808, min-1 = 9223372036854775807
max is 9223372036854775807, max+1 = -9223372036854775808
so these lines
expect(buffer.contains(min - 1), isFalse);
expect(buffer.contains(max + 1), isFalse);
fail. Since it wraps around, the values are contained in the buffer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, so contains didn't restrict the argument number to 64 bits before, but now it does. Makes sense. In that case, carry on!
test/typed_buffers_test.dart
Outdated
| 0x7aaaaaaaaaaaaaaa, | ||
| 0x7000000000000001, | ||
| 0x7000000000000000, | ||
| 0x7fffffffffffffff, // 2^63-1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The numerals were in numerical order, so do keep that.
| language: dart | ||
| dart: | ||
| - dev | ||
| - stable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this really need to drop stable? I don't see BigInt being used...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The except in the test returns different results on stable and dev, cause of difference in int64 behavior in the VM. Fixed it for dev16, but now it fails on stable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh...hrm...
Couldn't we modify the tests so they work on both?
My concern: if we drop testing for stable, we should likely drop it in the pubspec, too.
But it'd be nice to avoid that since – AFAICT – there is no behavior change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With dev 16, min-1=max and max+1=min for int 64, so it wraps around. So now min-1 and max+1 are contained in the buffer, whereas previously they were not. This is a corner case, but it is a change in behavior. So change the pubspec?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lrhn ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, change the pubspec to require the next version of the SDK,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kevmoo ptal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Fix test for Dart 2.0 ints * Update pubspec.yaml * Update typed_buffers_test.dart * Update typed_buffers_test.dart * Add 2^63 back to test data * Update CHANGELOG.md * Update typed_buffers_test.dart * Fix tests * run tests only on dev * Update pubspec
No description provided.