Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
eshamster committed Apr 8, 2018
2 parents 448cfa0 + 5221806 commit 162eb35
Show file tree
Hide file tree
Showing 17 changed files with 897 additions and 1,007 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Expand Up @@ -12,10 +12,10 @@ env:

install:
- curl -L https://raw.githubusercontent.com/snmsts/roswell/release/scripts/install-for-ci.sh | sh
- (cd ${ROSWELL_INSTALL_DIR}/local-projects ; git clone https://github.com/eshamster/ps-experiment.git)
- ros install eshamster/ps-experiment
- ros install fukamachi/rove
- ros -e '(ql:register-local-projects)' -q
- ros install ps-experiment

script:
- run-prove-for-ps *-test.asd
- rove *.asd

5 changes: 2 additions & 3 deletions src/basic-process.lisp → basic-process.lisp
@@ -1,5 +1,4 @@
(in-package :cl-user)
(defpackage cl-ps-ecs.basic-process
(defpackage cl-ps-ecs/basic-process
(:use :cl
:parenscript
:ps-experiment)
Expand All @@ -9,7 +8,7 @@
:register-next-frame-func
:register-nframes-after-func
:register-func-with-pred))
(in-package :cl-ps-ecs.basic-process)
(in-package :cl-ps-ecs/basic-process)

(defvar.ps+ *next-frame-func-list* '())

Expand Down
33 changes: 0 additions & 33 deletions cl-ps-ecs-test.asd

This file was deleted.

34 changes: 18 additions & 16 deletions cl-ps-ecs.asd
Expand Up @@ -7,28 +7,16 @@
Author: eshamster (hamgoostar@gmail.com)
|#

(in-package :cl-user)
(defpackage cl-ps-ecs-asd
(:use :cl :asdf))
(in-package :cl-ps-ecs-asd)

(defsystem cl-ps-ecs
:version "0.1"
:author "eshamster"
:license "LLGPL"
:class :package-inferred-system
:depends-on (:parenscript
:alexandria
:ps-experiment
:cl-reexport)
:components ((:module "src"
:serial t
:components
((:file "utils")
(:file "flat-tree")
(:file "basic-process")
(:file "frame-promise")
(:file "ecs")
(:file "cl-ps-ecs"))))
:cl-reexport
"cl-ps-ecs/main")
:description "[WIP] Entity-Component-System written by ParenScript (Common Lisp) "
:long-description
#.(with-open-file (stream (merge-pathnames
Expand All @@ -42,4 +30,18 @@
:fill-pointer t)))
(setf (fill-pointer seq) (read-sequence seq stream))
seq)))
:in-order-to ((test-op (test-op cl-ps-ecs-test))))
:in-order-to ((test-op (test-op cl-ps-ecs/t))))

(defsystem cl-ps-ecs/t
:class :package-inferred-system
:depends-on (:ps-experiment
:ps-experiment/t/test-utils
:parenscript
:cl-js
:rove
"cl-ps-ecs/t/utils"
"cl-ps-ecs/t/flat-tree"
"cl-ps-ecs/t/basic-process"
"cl-ps-ecs/t/frame-promise"
"cl-ps-ecs/t/ecs")
:perform (test-op (o c) (symbol-call :rove '#:run c)))
11 changes: 5 additions & 6 deletions src/ecs.lisp → ecs.lisp
@@ -1,11 +1,10 @@
(in-package :cl-user)
(defpackage cl-ps-ecs.ecs
(defpackage cl-ps-ecs/ecs
(:use :cl
:parenscript
:ps-experiment
:cl-ps-ecs.utils
:cl-ps-ecs.basic-process
:cl-ps-ecs.flat-tree)
:cl-ps-ecs/utils
:cl-ps-ecs/basic-process
:cl-ps-ecs/flat-tree)
(:export :includes-all-component-types
:ecs-component
:find-a-component
Expand Down Expand Up @@ -54,7 +53,7 @@
(:import-from :alexandria
:symbolicate
:with-gensyms))
(in-package :cl-ps-ecs.ecs)
(in-package :cl-ps-ecs/ecs)

;; ---- component ---- ;;
(defstruct.ps+ (ecs-component (:include flat-tree-node)))
Expand Down
4 changes: 2 additions & 2 deletions src/flat-tree.lisp → flat-tree.lisp
@@ -1,5 +1,5 @@
(in-package :cl-user)
(defpackage cl-ps-ecs.flat-tree
(defpackage cl-ps-ecs/flat-tree
(:use :cl
:parenscript
:ps-experiment)
Expand All @@ -17,7 +17,7 @@
:do-flat-tree-list
:delete-flat-tree-node
:delete-flat-tree-node-if))
(in-package :cl-ps-ecs.flat-tree)
(in-package :cl-ps-ecs/flat-tree)

;; This package is internally used for ecs-entity and ecs-component.
;; The structure is required for them.
Expand Down
6 changes: 3 additions & 3 deletions src/frame-promise.lisp → frame-promise.lisp
@@ -1,15 +1,15 @@
(in-package :cl-user)
(defpackage cl-ps-ecs.frame-promise
(defpackage cl-ps-ecs/frame-promise
(:use :cl
:parenscript
:ps-experiment
:cl-ps-ecs.basic-process)
:cl-ps-ecs/basic-process)
(:export :frame-promise
:frame-promise-p
:init-frame-promise
:frame-promise-then
:frame-promise-all))
(in-package :cl-ps-ecs.frame-promise)
(in-package :cl-ps-ecs/frame-promise)

;; The frame-promise is inspired from JavaScript's Promise.
;; It is checked that each frame-promise is resolved in first of frame (ecs-main).
Expand Down
12 changes: 12 additions & 0 deletions main.lisp
@@ -0,0 +1,12 @@
(defpackage cl-ps-ecs/main
(:nicknames :cl-ps-ecs)
(:use :cl-ps-ecs/ecs
:cl-ps-ecs/basic-process
:cl-ps-ecs/frame-promise))
(in-package :cl-ps-ecs/main)

(cl-reexport:reexport-from :cl-ps-ecs/ecs)
(cl-reexport:reexport-from :cl-ps-ecs/basic-process
:exclude '(:execute-ecs-basic-process
:clean-ecs-basic-process))
(cl-reexport:reexport-from :cl-ps-ecs/frame-promise)
13 changes: 0 additions & 13 deletions src/cl-ps-ecs.lisp

This file was deleted.

140 changes: 63 additions & 77 deletions t/basic-process.lisp
@@ -1,15 +1,11 @@
(in-package :cl-user)
(defpackage cl-ps-ecs-test.basic-process
(defpackage cl-ps-ecs/t/basic-process
(:use :cl
:cl-ps-ecs.basic-process
:cl-ps-ecs/basic-process
:parenscript
:ps-experiment
:prove)
(:import-from :ps-experiment-test.test-utils
:with-prove-in-both))
(in-package :cl-ps-ecs-test.basic-process)

(plan 3)
:rove
:ps-experiment/t/test-utils))
(in-package :cl-ps-ecs/t/basic-process)

(declaim #+sbcl (sb-ext:muffle-conditions sb-ext:compiler-note))

Expand All @@ -18,74 +14,64 @@
(progn ,@body)
(clean-ecs-basic-process)))

(subtest
"Test register-next-frame-func"
(with-prove-in-both ()
(with-modify-env
(let ((counter 0))
;; Check if 2 functions are executed in order of registration
(register-next-frame-func #'(lambda () (incf counter)))
(register-next-frame-func #'(lambda () (setf counter (* 2 counter))))
(is counter 0)
(incf counter 10)
(is counter 10)
(deftest.ps+ for-register-next-frame-func
(with-modify-env
(let ((counter 0))
;; Check if 2 functions are executed in order of registration
(register-next-frame-func #'(lambda () (incf counter)))
(register-next-frame-func #'(lambda () (setf counter (* 2 counter))))
(ok (= counter 0))
(incf counter 10)
(ok (= counter 10))
(execute-ecs-basic-process)
(ok (= counter 22))
;; Check if registered functions are cleared after execution
(execute-ecs-basic-process)
(ok (= counter 22)))))

(deftest.ps+ for-register-nframes-after-func
(with-modify-env
(let ((counter 0))
(flet ((make-adder (n)
(lambda () (incf counter n)))
(make-pred (border)
(lambda () (>= counter border))))
;; func1-1, 1-2
(register-nframes-after-func (make-adder 1) 0)
(register-nframes-after-func (make-adder 10) 1)
;; func2
(register-nframes-after-func (make-adder 100) 3)
(ok (= counter 0))
;; only func1-1 and 1-2 should be invoked (and removed)
(execute-ecs-basic-process)
(is counter 22)
;; Check if registered functions are cleared after execution
(ok (= counter 11))
;; nothing should be invoked
(execute-ecs-basic-process)
(is counter 22)))))

(subtest
"Test register-nframes-after-func"
(with-prove-in-both ()
(with-modify-env
(let ((counter 0))
(flet ((make-adder (n)
(lambda () (incf counter n)))
(make-pred (border)
(lambda () (>= counter border))))
;; func1-1, 1-2
(register-nframes-after-func (make-adder 1) 0)
(register-nframes-after-func (make-adder 10) 1)
;; func2
(register-nframes-after-func (make-adder 100) 3)
(is counter 0)
;; only func1-1 and 1-2 should be invoked (and removed)
(execute-ecs-basic-process)
(is counter 11)
;; nothing should be invoked
(execute-ecs-basic-process)
(is counter 11)
;; only func2 should be invokded
(execute-ecs-basic-process)
(is counter 111))))))

(subtest
"Test register-func-with-pred"
(with-prove-in-both ()
(with-modify-env
(let ((counter 0))
(flet ((make-adder (n)
(lambda () (incf counter n)))
(make-pred (border)
(lambda () (>= counter border))))
;; func1
(register-func-with-pred (make-adder 100) (make-pred 10))
;; func2
(register-func-with-pred (make-adder 10) (make-pred -1))
;; func3
(register-func-with-pred (make-adder 1000) (make-pred 999999)
:timeout-frame 3)
(is counter 0)
;; only func2 should be invoked (and removed)
(execute-ecs-basic-process)
(is counter 10)
;; only func1 should be invokded
(execute-ecs-basic-process)
(is counter 110)
;; should be timeout error because of func3
(is-error (execute-ecs-basic-process) 'simple-error))))))

;; ---- Start test ---- ;;
(ok (= counter 11))
;; only func2 should be invokded
(execute-ecs-basic-process)
(ok (= counter 111))))))

(finalize)
(deftest.ps+ for-register-func-with-pred
(with-modify-env
(let ((counter 0))
(flet ((make-adder (n)
(lambda () (incf counter n)))
(make-pred (border)
(lambda () (>= counter border))))
;; func1
(register-func-with-pred (make-adder 100) (make-pred 10))
;; func2
(register-func-with-pred (make-adder 10) (make-pred -1))
;; func3
(register-func-with-pred (make-adder 1000) (make-pred 999999)
:timeout-frame 3)
(ok (= counter 0))
;; only func2 should be invoked (and removed)
(execute-ecs-basic-process)
(ok (= counter 10))
;; only func1 should be invokded
(execute-ecs-basic-process)
(ok (= counter 110))
;; should be timeout error because of func3
(ok (signals (execute-ecs-basic-process) 'simple-error))))))
14 changes: 0 additions & 14 deletions t/cl-ps-ecs.lisp

This file was deleted.

0 comments on commit 162eb35

Please sign in to comment.