Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Conversation

@keertip
Copy link
Contributor

@keertip keertip commented Jan 9, 2018

No description provided.

Copy link
Contributor

@nex3 nex3 left a 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
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done?

Copy link
Contributor Author

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?

0x7aaaaaaaaaaaaaaa,
0x7000000000000001,
0x7000000000000000,
0x7fffffffffffffff, //2^63
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, it is.

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){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: ) {

Copy link
Contributor Author

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.

// 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Capitalization, punctuation.

Copy link
Contributor Author

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works, added back.

Copy link
Contributor

@nex3 nex3 left a 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.
Copy link
Contributor

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.

Copy link

@alexmarkov alexmarkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@keertip keertip requested a review from lrhn January 9, 2018 22:23
0x10000000000000000, // 2^64
0x0ffffffffffffffff,
0xaaaaaaaaaaaaaaaa,
0x8000000000000001,
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// as signed ints.
expect(buffer.contains(min - 1), isTrue);
} else {
expect(buffer.contains(min - 1), isFalse);
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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!

0x7aaaaaaaaaaaaaaa,
0x7000000000000001,
0x7000000000000000,
0x7fffffffffffffff, // 2^63-1
Copy link
Contributor

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
Copy link
Contributor

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...

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lrhn ?

Copy link
Contributor

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,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevmoo ptal.

Copy link
Contributor

@kevmoo kevmoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@keertip keertip merged commit 2d5ef0b into master Jan 17, 2018
@kevmoo kevmoo deleted the tests branch January 18, 2018 03:22
mosuem pushed a commit to dart-lang/core that referenced this pull request Oct 16, 2024
* 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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

6 participants