<commit_before>#= require lib/math/expression_components
#= require lib/math/expression_equality


describe "expression equality", ->
  beforeEach ->
    @comps = ttm.require('lib/math/expression_components')
    @isEqual = ttm.require('lib/math/expression_equality').isEqual
    @exp_builder = ttm.require('lib/math/build_expression_from_javascript_object').buildExpression

  describe "numbers", ->
    it "with different values are different", ->
      expect(
        @isEqual(
          @comps.number.build(value: 10),
          @comps.number.build(value: 11)
          )).toEqual false

    it "is equal with two of the same value", ->
      expect(
        @isEqual(
          @comps.number.build(value: 10),
          @comps.number.build(value: 10)
          )).toEqual true

  describe "expression comparison", ->
    it "accepts for empty expressions", ->
      expect(
        @isEqual(
          @comps.expression.build(),
          @comps.expression.build()
          )).toEqual true


    it "accepts expressions that have equal number internals", ->
      expect(
        @isEqual(
          @comps.expression.build(expression: [
              @comps.number.build(value: 10)
            ]),
          @comps.expression.build(expression: [
              @comps.number.build(value: 10)
            ])
          )).toEqual true

    it "rejects expressions with different numeric internals", ->
      expect(
        @isEqual(
          @comps.expression.build(expression: [
              @comps.number.build(value: 11)
            ]),
          @comps.expression.build(expression: [
              @comps.number.build(value: 10)
            ])
          )).toEqual false

    it "rejects expressions that are of different lengths", ->
      expect(
        @isEqual(
          @comps.expression.build(expression: []),
          @comps.expression.build(expression: [
              @comps.number.build(value: 10)
            ])
          )).toEqual false


  describe "addition", ->
    it "accepts two addition symbols", ->
      expect(
        @isEqual(
          @comps.addition.build(),
          @comps.addition.build()
        )).toEqual true


  describe "blank elements", ->
    it "accepts vs a blank element", ->
      expect(
        @isEqual(
          @comps.blank.build(),
          @comps.blank.build(),
        )).toEqual true

    it "rejects against numbers", ->
      expect(
        @isEqual(
          @comps.blank.build(),
          @comps.number.build(value: 1)
        )).toEqual false


  describe "exponentiation", ->
    it "accepts exponents with same base and power", ->
      a = @exp_builder('^': [11, 22])
      b = @exp_builder('^': [11, 22])
      expect(a).toBeAnEqualExpressionTo b

    it "rejects exponents with differing bases", ->
      new_exp = @exp_builder('^': [11, 32])
      expected = @exp_builder('^': [12, 32])
      expect(new_exp).not.toBeAnEqualExpressionTo(expected)

    it "rejects exponents different powers",->
      new_exp = @exp_builder('^': [10, 32])
      expected = @exp_builder('^': [10, 22])
      expect(new_exp).not.toBeAnEqualExpressionTo(expected)



<commit_msg>Filled out additional missing types for testing expression equality<commit_after>#= require lib/math/expression_components
#= require lib/math/expression_equality


describe "expression equality", ->
  beforeEach ->
    @comps = ttm.require('lib/math/expression_components')
    @isEqual = ttm.require('lib/math/expression_equality').isEqual
    @exp_builder = ttm.require('lib/math/build_expression_from_javascript_object').buildExpression

  describe "numbers", ->
    it "with different values are different", ->
      expect(
        @isEqual(
          @comps.number.build(value: 10),
          @comps.number.build(value: 11)
          )).toEqual false

    it "is equal with two of the same value", ->
      expect(
        @isEqual(
          @comps.number.build(value: 10),
          @comps.number.build(value: 10)
          )).toEqual true


  describe "expression comparison", ->
    it "accepts for empty expressions", ->
      expect(
        @isEqual(
          @comps.expression.build(),
          @comps.expression.build()
          )).toEqual true


    it "accepts expressions that have equal number internals", ->
      expect(
        @isEqual(
          @comps.expression.build(expression: [
              @comps.number.build(value: 10)
            ]),
          @comps.expression.build(expression: [
              @comps.number.build(value: 10)
            ])
          )).toEqual true

    it "rejects expressions with different numeric internals", ->
      expect(
        @isEqual(
          @comps.expression.build(expression: [
              @comps.number.build(value: 11)
            ]),
          @comps.expression.build(expression: [
              @comps.number.build(value: 10)
            ])
          )).toEqual false

    it "rejects expressions that are of different lengths", ->
      expect(
        @isEqual(
          @comps.expression.build(expression: []),
          @comps.expression.build(expression: [
              @comps.number.build(value: 10)
            ])
          )).toEqual false


  describe "addition", ->
    it "accepts two addition symbols", ->
      expect(
        @isEqual(
          @comps.addition.build(),
          @comps.addition.build()
        )).toEqual true


  describe "blank elements", ->
    it "accepts vs a blank element", ->
      expect(
        @isEqual(
          @comps.blank.build(),
          @comps.blank.build(),
        )).toEqual true

    it "rejects against numbers", ->
      expect(
        @isEqual(
          @comps.blank.build(),
          @comps.number.build(value: 1)
        )).toEqual false


  describe "exponentiation", ->
    it "accepts exponents with same base and power", ->
      a = @exp_builder('^': [11, 22])
      b = @exp_builder('^': [11, 22])
      expect(a).toBeAnEqualExpressionTo b

    it "rejects exponents with differing bases", ->
      new_exp = @exp_builder('^': [11, 32])
      expected = @exp_builder('^': [12, 32])
      expect(new_exp).not.toBeAnEqualExpressionTo(expected)

    it "rejects exponents different powers",->
      new_exp = @exp_builder('^': [10, 32])
      expected = @exp_builder('^': [10, 22])
      expect(new_exp).not.toBeAnEqualExpressionTo(expected)

  describe "multiplication", ->
    it "accepts two multiplication symbols", ->
      expect(
        @isEqual(
          @comps.multiplication.build(),
          @comps.multiplication.build()
        )).toEqual true

  describe "division", ->
    it "accepts two division symbols", ->
      expect(
        @isEqual(
          @comps.division.build(),
          @comps.division.build()
        )).toEqual true

  describe "pi", ->
    it "accepts two pi symbols", ->
      expect(
        @isEqual(
          @comps.pi.build(),
          @comps.pi.build()
        )).toEqual true

  describe "subtraction", ->
    it "accepts two subtraction symbols", ->
      expect(
        @isEqual(
          @comps.subtraction.build(),
          @comps.subtraction.build()
        )).toEqual true

{'fraction_non_alphanumeric': 0.13303396014594443, 'fraction_numerical': 0.012068481616615213, 'mean_word_length': 2.1081552551242915, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2747424', 'n_tokens_mistral': 2175, 'n_tokens_neox': 2029, 'n_words': 462}