Skip to content

Commit

Permalink
Lint fixes for numerical literals
Browse files Browse the repository at this point in the history
  • Loading branch information
boopathi committed Oct 26, 2016
1 parent 8d17070 commit ba7741d
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ jest.autoMockOff();

const babel = require("babel-core");
const plugin = require("../src/index");
const unpad = require("../../../utils/unpad");

function transform(code) {
return babel.transform(code, {
Expand All @@ -13,25 +12,25 @@ function transform(code) {
describe("numeric-literals", () => {
it("should shorten properly", () => {

let source = '[10, 100, 1000, 10000, -2, -30000];';
let expected = '[10, 100, 1e3, 1e4, -2, -3e4];'
let source = "[10, 100, 1000, 10000, -2, -30000];";
let expected = "[10, 100, 1e3, 1e4, -2, -3e4];";

expect(transform(source)).toBe(expected);

source = '[1e3, -1e4, 1e-5, 1.5e12, 1.23456, .1];';
expected = '[1e3, -1e4, 1e-5, 1.5e12, 1.23456, .1];';
source = "[1e3, -1e4, 1e-5, 1.5e12, 1.23456, .1];";
expected = "[1e3, -1e4, 1e-5, 1.5e12, 1.23456, .1];";

expect(transform(source)).toBe(expected);

source = '[0x000001, 0o23420, 0b10011100010000];';
expected = '[1, 1e4, 1e4];';
source = "[0x000001, 0o23420, 0b10011100010000];";
expected = "[1, 1e4, 1e4];";

expect(transform(source)).toBe(expected);

source = '[+0.000000000001, -0.00000000001];';
source = "[+0.000000000001, -0.00000000001];";
// TODO: this seems to be specific to how Babel outputs number
// for some reason it adds + in the beginning
expected = '[+1e-12, -1e-11];';
expected = "[+1e-12, -1e-11];";

expect(transform(source)).toBe(expected);
});
Expand Down

0 comments on commit ba7741d

Please sign in to comment.