Repository: mozilla/pdf.js
File: test/unit/parser_spec.js (JavaScript)

Code before:
    });

    describe("peekChar", function () {
      it("should only return -1 when the end of the stream is reached", function () {
        const input = new StringStream("");
        const lexer = new Lexer(input);
        expect(lexer.peekChar()).toEqual(-1);
        expect(lexer.currentChar).toEqual(-1);
      });

      it("should only return the character after the current position", function () {
        const input = new StringStream("123");
        const lexer = new Lexer(input);
        expect(lexer.peekChar()).toEqual(0x32); // '2'
        expect(lexer.currentChar).toEqual(0x31); // '1'
      });
    });

    describe("getNumber", function () {
      it("should stop parsing numbers at the end of stream", function () {
        const input = new StringStream("11.234");
        const lexer = new Lexer(input);
        expect(lexer.getNumber()).toEqual(11.234);
      });

      it("should ignore double negative before number", function () {
        const input = new StringStream("--205.88");
        const lexer = new Lexer(input);
        expect(lexer.getNumber()).toEqual(-205.88);
      });

      it("should ignore minus signs in the middle of number", function () {
        const input = new StringStream("205--.88");
        const lexer = new Lexer(input);
        expect(lexer.getNumber()).toEqual(205.88);
      });

      it("should ignore line-breaks between operator and digit in number", function () {
        const minusInput = new StringStream("-\r\n205.88");
        const minusLexer = new Lexer(minusInput);
        expect(minusLexer.getNumber()).toEqual(-205.88);

        const plusInput = new StringStream("+\r\n205.88");
        const plusLexer = new Lexer(plusInput);
        expect(plusLexer.getNumber()).toEqual(205.88);
      });

      it("should treat a single decimal point, or minus/plus sign, as zero", function () {
        const validNums = [
          ".",
          "-",

Review comment (suggestion):
Most of the cases below have nothing to do with scientific notation, so this test should obviously not just be outright removed.

Code after:
    });

    describe("peekChar", function () {
      it("should only return -1 when the end of the stream is reached", function () {
        const input = new StringStream("");
        const lexer = new Lexer(input);
        expect(lexer.peekChar()).toEqual(-1);
        expect(lexer.currentChar).toEqual(-1);
      });

      it("should only return the character after the current position", function () {
        const input = new StringStream("123");
        const lexer = new Lexer(input);
        expect(lexer.peekChar()).toEqual(0x32); // '2'
        expect(lexer.currentChar).toEqual(0x31); // '1'
      });
    });

    describe("getNumber", function () {
      it("should stop parsing numbers at the end of stream", function () {
        const input = new StringStream("11.234");
        const lexer = new Lexer(input);
        expect(lexer.getNumber()).toEqual(11.234);
      });

      it("should parse PDF numbers", function () {
        const numbers = [
          "-.002",
          "34.5",
          "-3.62",
          "-1.",
          "0.0",
          "123",
          "-98",
          "43445",
          "0",
          "+17",
        ];
        for (const number of numbers) {
          const input = new StringStream(number);
          const lexer = new Lexer(input);

          const result = lexer.getNumber(),
            expected = parseFloat(number);

          if (result !== expected && Math.abs(result - expected) < 1e-15) {
            console.error(
              `Fuzzy matching "${result}" with "${expected}" to ` +
                "work-around rounding bugs in Chromium browsers."
            );