Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
[RC Diary] Getting data to have Cerebro in good shape (-63)

[RC Diary] Getting data to have Cerebro in good shape (-63)

Project lamp

I've been reading the chapter on continuations, I am starting to get them, possibly I just need to give it a couple more reads.

Getting data for Cerebro

First thing was mitigate the terrible data structure mutation I have to do when passing source code into a mutation, I want to copy the source and pass then into the mutation. It appears to be extremely difficult to do.

I wrote a script to get repos from Github that depend on mocha, which is the only test runner I currently support.

Now for the next bit, clone some of those and then

  • run Cerebro
  • see if fail
  • fix it
  • get the next
  • adapt Cerebro
  • repeat

I also managed to return both the mutated and original code from the mutation, so now I can clean a bit core.cljs, which was starting to become a real mess. It seems like a small thing but took me half today to figure out how to do it, it basically involved understanding a bit more about how JavaScript interop works:

(defn loop-nodes
  "applies a mutation to the ASTs,
  returns the mutated, or non mutated, ASTs"
  (let [original-code (.parse js/JSON (.stringify js/JSON (candidate :code)))]
    (.visit esrecurse (candidate :code) (clj->js {:BinaryExpression mutate}))
    (hash-map :original
              (hash-map :path (candidate :path) :code original-code)
              (hash-map :path (candidate :path) :code (candidate :code)))))

this is the code that applies a mutation, (candidate :code) (ah BTW, so nice that in ClojureScript hashmaps are functions!) containes the AST, and it is passed through esrecurse and the mutated in mutate. What I had to do is basically a copy of (candidate :code), via the stringify and parse horrible bit. I should update that to use a less hacky system and put it where it could be used by other mutations.

The little schemer

I've tried going through chapter 6 for a couple hours. Failed. Coulnd't really focus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.