Up to Main Index Up to Journal for November, 2022
JOURNAL FOR SUNDAY 20TH NOVEMBER, 2022
______________________________________________________________________________
SUBJECT: A quick state of play update
DATE: Sun 20 Nov 19:40:23 GMT 2022
I’ve just realised it’s late November and I have not written anything since
Halloween, and people are starting to ask questions about what’s going on…
In a nutshell, I’ve been very busy with work to pay the bills. I’ve recently
overhauled the company’s servers and then started a development contract with
a new client. I’ve also been feeling ghastly after getting my latest COVID and
flu shots. Just like last time, the shots are really making my hands ache :P
When I get any spare time I’m hacking away on Mere. I’m still rewriting the
operators and built-ins due to reworking the internal variable storage. The
language is slowly coming together again and there are quite a few additional
improvements under the hood.
As each operator and built-in is rewritten a bucket load of unit tests are
added. Of the 40 operators, 32 have tests. Of the 26 testable built-ins, 16
have tests. I currently have 50 odd test files with over 2700 asserts. Running
the tests gives me a short report:
b_assert.mr 68μs
b_bool_array.mr 116μs
b_bool_map.mr 245μs
b_delete.mr 176μs
b_exists.mr 114μs
b_float_array.mr 128μs
b_goto.mr 11μs
b_int_array.mr 121μs
b_int_map.mr 201μs
b_keys.mr 38μs
b_len.mr 47μs
b_literal.mr 363μs
b_sort.mr 82μs
b_sprint.mr 145μs
b_string_array.mr 133μs
b_substr.mr 14μs
issues.mr 92μs
op_add.mr 44μs
op_and.mr 20μs
op_assign.mr 352μs
op_bool.mr 41μs
op_dec.mr 29μs
op_div.mr 17μs
op_eq.mr 109μs
op_float.mr 68μs
op_ge.mr 47μs
op_gt.mr 51μs
op_inc.mr 32μs
op_index_assign.mr 905μs
op_index.mr 112μs
op_int.mr 29μs
op_land.mr 22μs
op_le.mr 49μs
op_lor.mr 22μs
op_lt.mr 49μs
op_mod.mr 13μs
op_mult_assign.mr 7μs
op_mult.mr 20μs
op_neg.mr 29μs
op_ne.mr 106μs
op_not.mr 16μs
op_or.mr 19μs
op_shift_left.mr 17μs
op_shift_right.mr 15μs
op_spaceship.mr 74μs
op_string.mr 118μs
op_sub.mr 36μs
op_type.mr 26μs
op_xor.mr 19μs
Passed: 49/49, 0 failures.
Not too exciting. I need to write a testing wrapper for Mere and these tests
so I can use Go’s standard testing tooling. At the moment I just use an ugly
Bash script:
#!/bin/bash
for i in `ls ./*.mr`; do
printf "%-20s " `basename $i`
../bin/mere $i
if [ "$?" -ne "0" ]; then
fail=$(($fail+1))
else
pass=$(($pass+1))
fi
total=$(($total+1))
done
printf "\n\tPassed: %d/%d, %d failures.\n\n" $pass $total $fail
It works. Using standard tooling would let me get some meaningful benchmarks.
For those interested in what the tests look like, here is the test for the
increment (x++) operator:
# Testing for inc operator
end:int; start:int=time
// int variables
ai:int
bi:int
ai = 1 ; assert ai 1
ai++ ; assert ai 2
bi = ai++ ; assert ai 3
; assert bi 3
bi = ai++++ ; assert ai 4
; assert bi 5
// int literals
assert 1++, 2
assert 1++++, 3
// int anonymous values
assert((1+1)++, 3)
assert((1+1)++++, 4)
// int array element
ia:[]int = []int 1
ia[0]++; assert ia[0] 2
// int map element
im:[int] = [int] 1 2
im[1]++; assert im[1] 3
// float variables
af:float
bf:float
af = 1.5 ; assert af 1.5
af++ ; assert af 2.5
bf = af++ ; assert af 3.5
; assert bf 3.5
bf = af++++ ; assert af 4.5
; assert bf 5.5
// float literals
assert 1.5++, 2.5
assert 1.5++++, 3.5
// float anonymous values
assert((1.5+1.1)++, 3.6)
assert((1.5+1.1)++++, 4.6)
// float array element
fa:[]float = []float 1.1
fa[0]++; assert fa[0] 2.1
// float map element
fm:[float] = [float] 1.1 2.2
fm[1.1]++; assert fm[1.1] 3.2
// manual iota...
iota:int = 0
assert [int]((iota++) "a", (iota++) "b") [int](1 "a", 2 "b")
end=time();printf "%6dμs\n" end-start
Note that due to a change in the assert built-in the above test will not run
in the online Mere ICE v0.0.4. Before assert took an expression and a message:
assert true==false, "true is not false"
assertion failed: true is not false
0: assert true == false , "true is not false"
Now assert takes two expressions. If they are not equal to each other it
generates its own message and complains:
assert true false
assertion failed
have: bool true
want: bool false
0: assert true false
I hope to update the online Mere ICE to v0.0.5 soon. For now, that’s it. Not
sure how much longer I’ll spend on Mere. However, this is all looking quite
promising and I’m still having fun :)
--
Diddymus
Up to Main Index Up to Journal for November, 2022