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

fix(reduce-idents): improve encode #862

Merged
merged 2 commits into from Jan 3, 2020
Merged

Conversation

defcc
Copy link
Contributor

@defcc defcc commented Dec 30, 2019

fix #853

@codecov-io
Copy link

codecov-io commented Dec 30, 2019

Codecov Report

Merging #862 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #862      +/-   ##
==========================================
+ Coverage   97.66%   97.66%   +<.01%     
==========================================
  Files         111      111              
  Lines        3338     3339       +1     
  Branches     1011     1011              
==========================================
+ Hits         3260     3261       +1     
  Misses         71       71              
  Partials        7        7
Impacted Files Coverage Δ
packages/postcss-reduce-idents/src/lib/encode.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8243401...d21abbe. Read the comment docs.

@alexander-akait
Copy link
Member

/cc @ben-eb can you look at this?

ben-eb
ben-eb previously approved these changes Dec 30, 2019
Copy link
Collaborator

@ben-eb ben-eb left a comment

Choose a reason for hiding this comment

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

Looks great! I think out of the scope of this PR but I'm not a fan of how we test the encoder here. Do you have any suggestions? One I was thinking about recently was having some kind of test "oracle" which would return specific character pairs to capture the edge cases, then test the real implementation against it. Something like:

const oracle = (val, num) => ({ 51: 'Z', 52: 'aa' }[num]);

...

expect(encode(null, num)).toBe(oracle(null, num));

What do you think? Possibly with a few more cases in there? 🙂

@defcc
Copy link
Contributor Author

defcc commented Dec 30, 2019

Thanks, I totally agree with you. I could add more edge cases according to the encoder spec with hardcode later.

—-
There maybe another way to test it with a decode util,x=decode(encode(x)),but then we have to ensure both two are correct:)

Copy link
Collaborator

@ben-eb ben-eb left a comment

Choose a reason for hiding this comment

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

Looks great, thanks! 💯

@alexander-akait alexander-akait merged commit c7b5879 into cssnano:master Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

postcss-reduce-idents' encoder could be more efficient
4 participants