workspace.silent = true
workspace.openFromSource(url2String("file:resources/empty.nlogo"))
-val commands = io.Source.stdin.getLines.mkString("\n")
+val input = io.Source.stdin.getLines.mkString("\n").split("\\@\\#\\$\\#\\@\\#\\$\\#\\@")
+val commands = input(0)
workspace.mainRNG.setSeed(15)
-workspace.runCompiledCommands(new api.SimpleJobOwner("test", workspace.world.mainRNG, api.AgentKind.Observer), workspace.compileCommands(commands, api.AgentKind.Observer))
+if(commands.length > 0) {
+ workspace.runCompiledCommands(new api.SimpleJobOwner("test", workspace.world.mainRNG, api.AgentKind.Observer), workspace.compileCommands(commands, api.AgentKind.Observer))
+}
+if(input.length > 0) {
+ val reporter = input(1)
+ System.out.println(org.nlogo.api.Dump.logoObject(workspace.runCompiledReporter(new api.SimpleJobOwner("test", workspace.world.mainRNG, api.AgentKind.Observer), workspace.compileReporter(reporter))))
+}
workspace.world.exportWorld(new java.io.PrintWriter(System.out, true), true)
System.out.println(org.nlogo.headless.Checksummer.calculateChecksum(workspace.world.exportWorld(_, true)))
+++ /dev/null
-#!/bin/sh
-exec scalas "$0" -q "$@"
-!#
-
-/***
- logLevel := Level.Error
-
- logLevel in Global := Level.Error
-
- scalaVersion := "2.10.3"
-
- libraryDependencies ++= Seq(
- "asm" % "asm-all" % "3.3.1",
- "org.picocontainer" % "picocontainer" % "2.13.6",
- "org.nlogo" % "NetLogo" % "6.0.0-M3" from "http://ccl.northwestern.edu/devel/6.0.0-M3/NetLogo.jar",
- "org.nlogo" % "NetLogoHeadless" % "6.0.0-M3" from "http://ccl.northwestern.edu/devel/6.0.0-M3/NetLogoHeadless.jar"
- )
-*/
-
-import org.nlogo.headless.HeadlessWorkspace
-import org.nlogo.mirror
-import org.nlogo.api
-import org.nlogo.nvm
-import org.nlogo.util.Utils.url2String
-
-System.out.println("----")
-val workspace = HeadlessWorkspace.newInstance
-workspace.silent = true
-workspace.openFromSource(url2String("file:resources/empty.nlogo"))
-
-val reporter = io.Source.stdin.getLines.mkString("\n")
-
-workspace.mainRNG.setSeed(15)
-System.out.println(org.nlogo.api.Dump.logoObject(workspace.runCompiledReporter(new api.SimpleJobOwner("test", workspace.world.mainRNG, api.AgentKind.Observer), workspace.compileReporter(reporter))))
-
-workspace.world.exportWorld(new java.io.PrintWriter(System.out, true), true)
-System.out.println(org.nlogo.headless.Checksummer.calculateChecksum(workspace.world.exportWorld(_, true)))
-workspace.dispose
(defsimpleprim :+ :reporter cl:+)
(defsimpleprim :* :reporter cl:*)
(defsimpleprim :/ :reporter cl:/)
+(defprim :any? :reporter (lambda (agentset) `(> (length ,agentset) 0)))
(defsimpleprim :ask :command clnl-nvm:ask)
(defsimpleprim :crt :command clnl-nvm:create-turtles)
(defsimpleprim :fd :command clnl-nvm:forward)
(funcall (intern "DUMP-OBJECT" :clnl-nvm) (clnl:run-reporter ,reporter))
(clnl-nvm:export-world)
(checksum-world)))
- "bin/runreporter.scala"
- (format nil "~A~%" ,reporter)))
+ "bin/runcmd.scala"
+ (format nil "~%@#$#@#$#@~A~%" ,reporter)))
+
+(defmacro defreportertestwithsetup (name setup reporter value checksum)
+ `(defsimpletest
+ (format nil "Reporter With Setup - ~A" ,name)
+ (lambda ()
+ (clnl:boot "resources/empty.nlogo")
+ (clnl:run-commands ,setup)
+ (and
+ (string= (funcall (intern "DUMP-OBJECT" :clnl-nvm) (clnl:run-reporter ,reporter)) ,value)
+ (checksum= ,checksum (checksum-world))))
+ (lambda ()
+ (clnl:boot "resources/empty.nlogo")
+ (clnl:run-commands ,setup)
+ (format nil "~A~%~A~A"
+ (funcall (intern "DUMP-OBJECT" :clnl-nvm) (clnl:run-reporter ,reporter))
+ (clnl-nvm:export-world)
+ (checksum-world)))
+ "bin/runcmd.scala"
+ (format nil "~A~%@#$#@#$#@~A" ,setup ,reporter)))
(defmacro defviewtest (name commands checksum)
`(defsimpletest
(defsimplereportertest "<= 3" "random-float 4 <= random-float 7" "false"
"811837B74F63D10ABBC01DD59C1E7556706D9F7A")
+
+(defsimplereportertest "any? 1" "any? turtles" "false"
+ "E1DE30F072D785E0D0B59F28B0F7853E3D3E0D8B")
+
+(defreportertestwithsetup "any? 2" "crt 10" "any? turtles" "true"
+ "A925E39EC022967568D238D31F70F0A375024A89")