Refactor Examples to use assert_eq
This commit updates all example files to use `assert_eq!` for verifying output, replacing the previous `Output:` comments. This change makes the examples more robust and self-testing. The benchmark results in some examples have also been slightly adjusted, reflecting minor performance variations after the refactoring. Additionally, a runtime panic handling mechanism has been introduced in the VM for function calls, which improves error reporting for unexpected panics.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
;; Output: 26.7
|
||||
;; Benchmark: 890ns
|
||||
;; Benchmark-Repeat: 2240
|
||||
;; Benchmark: 1.1us
|
||||
;; Benchmark-Repeat: 1877
|
||||
(do
|
||||
(def my_ticks (series 100 {:price :float :volume :int :msg :text}))
|
||||
|
||||
@@ -8,10 +7,8 @@
|
||||
(push my_ticks {:price 11.2 :volume 200 :msg "B"})
|
||||
(push my_ticks {:price 15.5 :volume 300 :msg "C"})
|
||||
|
||||
;(repeat n 100 (push my_ticks {:price (+ n 15.5) :volume (ceil (/ n 300)) :msg "??"})
|
||||
|
||||
|
||||
(def prices (.price my_ticks))
|
||||
|
||||
(+ (prices 0) (prices 1))
|
||||
;; prices 0 = 15.5 (newest), prices 1 = 11.2
|
||||
(assert-eq 26.7 (+ (prices 0) (prices 1)))
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user