Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add basic unit-tests for murmurhash3.js #7857

Merged
merged 1 commit into from
Dec 1, 2016

Conversation

jabiinfante
Copy link
Contributor

It adds some tests for murmurhash3 as suggested on #7261

Copy link
Contributor

@timvandermeij timvandermeij left a comment

Choose a reason for hiding this comment

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

Nice work! This commit looks good to me with the comments addressed. Don't forget to squash multiple commits into one commit after addressing the comments (see https://github.com/mozilla/pdf.js/wiki/Squashing-Commits for how to do this easily if you're not familiar with the concept).

@@ -0,0 +1,53 @@
/* globals jasmine, expect, it, describe, MurmurHash3_64 */
'use strict';
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: add a newline before this line.

'use strict';

describe('MurmurHash3_64', function() {

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: remove this newline.

hexdigest2 = hash.hexdigest();
expect(hexdigest1).not.toEqual(hexdigest2);
});

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: remove this newline.

describe('MurmurHash3_64', function() {

it('instantiates without seed ', function() {
var hash = new MurmurHash3_64();
Copy link
Contributor

Choose a reason for hiding this comment

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

Indent this line with two spaces instead of four, i.e., remove two spaces. We always indent with two spaces. This also applies to the other occurrences in this file.


describe('MurmurHash3_64', function() {

it('instantiates without seed ', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: remove the space at the end of the string. This also applies to the unit test below.


var hexDigestExpected = 'f61cfdbfdae0f65e';
var sourceText = 'test';
var sourceCharCodes = [116,101,115,116]; // 't','e','s','t'
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: add spaces after each comma.

var hexDigestExpected = 'f61cfdbfdae0f65e';
var sourceText = 'test';
var sourceCharCodes = [116,101,115,116]; // 't','e','s','t'
it('generates expected from string', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would change this to correctly generates a hash from a string (and Uint8Array/Uint32Array below) as it's a bit more descriptive in the logs when running the unit tests.

expect(hash.hexdigest()).toEqual(hexDigestExpected);
});

it('hexdigest changes after update without seed', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would change this to changes the hash after update without seed (and similar for the test below) to make it more readable in combination with the it function.

it('hexdigest changes after update without seed', function() {
var hash = new MurmurHash3_64();
var hexdigest1, hexdigest2;
hash.update('test');
Copy link
Collaborator

@Snuffleupagus Snuffleupagus Nov 30, 2016

Choose a reason for hiding this comment

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

Since you defined var sourceText = 'test'; above, any reason not to just use hash.update(sourceText); here instead?
(This question applies in a couple of places below as well.)

@jabiinfante
Copy link
Contributor Author

@timvandermeij and @Snuffleupagus thanks for your comments.
They should be applied now.

@timvandermeij
Copy link
Contributor

/botio unittest

@pdfjsbot
Copy link

pdfjsbot commented Dec 1, 2016

From: Bot.io (Windows)


Received

Command cmd_unittest from @timvandermeij received. Current queue size: 0

Live output at: http://107.22.172.223:8877/422569bf689d9d5/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Dec 1, 2016

From: Bot.io (Linux)


Received

Command cmd_unittest from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/16c5f2515c45bb2/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Dec 1, 2016

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/16c5f2515c45bb2/output.txt

Total script time: 1.98 mins

  • Unit Tests: Passed

@pdfjsbot
Copy link

pdfjsbot commented Dec 1, 2016

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/422569bf689d9d5/output.txt

Total script time: 2.71 mins

  • Unit Tests: Passed

@timvandermeij timvandermeij merged commit 46d2c89 into mozilla:master Dec 1, 2016
@timvandermeij
Copy link
Contributor

Thank you for the patch!

@jabiinfante jabiinfante deleted the murmurhash3-unit-tests branch February 6, 2017 07:58
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants