<commit_before>(ns vineyard.hello-world-test
  (:require [vineyard.core :as core]
            [vineyard.compiler :as compiler]
            [vineyard.parser :as parser]
            [clojure.test :as t :refer [deftest is]]
            [clojure.java.io :as io]
            [clojure.java.shell :as shell]
            [clojure.string :as str]))

(defn source []
  (slurp (io/resource "01_hello_world.vy")))

(defn sexp []
  (read-string (slurp (io/resource "01_hello_world.clj"))))

(defn js []
  (slurp (io/resource "01_hello_world.js")))

(defn out []
  (slurp (io/resource "01_hello_world.out")))

(defn error-free [out]
  {:exit 0
   :out out
   :err ""})

(defn run [code]
  (let [path "target/out.js"]
    (core/save code path)
    (shell/sh "node" path)))

(deftest runs-end-to-end
  (let [parsed   (parser/parse (source))
        compiled (compiler/compile parsed)
        ran      (run compiled)]
    ;; This is intermetently failing for no good reason. The things that should
    ;; be equal are printing as equal.
    ;; (is (= (sexp) parsed))
    (is (= (str/trim (js)) compiled))
    (is (= (error-free (out)) ran))))<commit_msg>added back in sexp assertion<commit_after>(ns vineyard.hello-world-test
  (:require [vineyard.core :as core]
            [vineyard.compiler :as compiler]
            [vineyard.parser :as parser]
            [clojure.test :as t :refer [deftest is]]
            [clojure.java.io :as io]
            [clojure.java.shell :as shell]
            [clojure.string :as str]))

(defn source []
  (slurp (io/resource "01_hello_world.vy")))

(defn sexp []
  (read-string (slurp (io/resource "01_hello_world.clj"))))

(defn js []
  (slurp (io/resource "01_hello_world.js")))

(defn out []
  (slurp (io/resource "01_hello_world.out")))

(defn error-free [out]
  {:exit 0
   :out out
   :err ""})

(defn run [code]
  (let [path "target/out.js"]
    (core/save code path)
    (shell/sh "node" path)))

(deftest runs-end-to-end
  (let [parsed   (parser/parse (source))
        compiled (compiler/compile parsed)
        ran      (run compiled)]
    (is (= (sexp) parsed))
    (is (= (str/trim (js)) compiled))
    (is (= (error-free (out)) ran))))
{'fraction_non_alphanumeric': 0.16335948315643747, 'fraction_numerical': 0.008306414397784956, 'mean_word_length': 2.6996587030716723, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7229975', 'n_tokens_mistral': 819, 'n_tokens_neox': 794, 'n_words': 203}