<commit_before>(ns push.instructions.base.integer_test
  (:require [push.interpreter.interpreter-core :as i])
  (:use [push.instructions.base.integer])
  (:use midje.sweet)
  (:use [push.util.test-helpers]))


;; fixtures


(def knows-some-integers
    (i/make-interpreter 
      :stacks {:integer '(11 -5 3333333333333333333 7777777777777777777)}))
      ;; the last two, when added, push us over the interger overflow limit


; setup-stack items instruction read-stack


(tabular
  (fact ":integer-add returns the sum, auto-promoting overflows"
    (step-and-check-it ?set-stack ?items ?instruction ?get-stack) ?arrow ?expected)

    ?set-stack  ?items    ?instruction  ?get-stack   ?arrow   ?expected
    ;; adding
    :integer    '(11 -5)  integer-add   :integer     =>       '(6)
    :integer    '(-3 -5)  integer-add   :integer     =>       '(-8)
    ;; missing args
    :integer    '(11)     integer-add   :integer     =>       '(11)
    :integer    '()       integer-add   :integer     =>       '()
    ;; overflow
    :integer    '(3333333333333333333 7777777777777777777)
                          integer-add   :integer     =>       '(11111111111111111110N))


(tabular
  (fact ":integer-subtract returns (- :second :first)"
    (step-and-check-it ?set-stack ?items ?instruction ?get-stack) ?arrow ?expected)

    ?set-stack  ?items    ?instruction       ?get-stack   ?arrow   ?expected
    ;; just the math
    :integer    '(11 -5)  integer-subtract   :integer     =>       '(16)
    :integer    '(-3 -5)  integer-subtract   :integer     =>       '(2)
    ;; missing args
    :integer    '(11)     integer-subtract   :integer     =>       '(11)<commit_msg>cleaned up leftover fixtures and notes in tests<commit_after>(ns push.instructions.base.integer_test
  (:require [push.interpreter.interpreter-core :as i])
  (:use [push.instructions.base.integer])
  (:use midje.sweet)
  (:use [push.util.test-helpers]))


(tabular
  (fact ":integer-add returns the sum, auto-promoting overflows"
    (step-and-check-it ?set-stack ?items ?instruction ?get-stack) ?arrow ?expected)

    ?set-stack  ?items    ?instruction  ?get-stack   ?arrow   ?expected
    ;; adding
    :integer    '(11 -5)  integer-add   :integer     =>       '(6)
    :integer    '(-3 -5)  integer-add   :integer     =>       '(-8)
    ;; missing args
    :integer    '(11)     integer-add   :integer     =>       '(11)
    :integer    '()       integer-add   :integer     =>       '()
    ;; overflow
    :integer    '(3333333333333333333 7777777777777777777)
                          integer-add   :integer     =>       '(11111111111111111110N))


(tabular
  (fact ":integer-subtract returns (- :second :first)"
    (step-and-check-it ?set-stack ?items ?instruction ?get-stack) ?arrow ?expected)

    ?set-stack  ?items    ?instruction       ?get-stack   ?arrow   ?expected
    ;; just the math
    :integer    '(11 -5)  integer-subtract   :integer     =>       '(16)
    :integer    '(-3 -5)  integer-subtract   :integer     =>       '(2)
    ;; missing args
    :integer    '(11)     integer-subtract   :integer     =>       '(11)
{'fraction_non_alphanumeric': 0.14065014483424526, 'fraction_numerical': 0.0653363373028645, 'mean_word_length': 2.295864262990456, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 8, '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': '2357774', 'n_tokens_mistral': 1165, 'n_tokens_neox': 982, 'n_words': 240}