DiceParser icon indicating copy to clipboard operation
DiceParser copied to clipboard

Creating a list of constant: `m` give wrong results / core dumps, parenthesis with multiples sub-expression either

Open robinmoussu opened this issue 6 years ago • 2 comments

I was trying to write unit test, and I was searching a was trying to find the best way to have deterministic test (I would like to use constant instead of dices to test the operators).

I don't this issue need to be fixed now, I just would like to have a workaround.

$dice "3;4;5;1;ms"
zsh: segmentation fault (core dumped)  ./*/bin/dice "3;4;5;1;ms"

With d1 instead of constant it doesn't work either:

$dice "3d1;4d1;5d1;1d1;ms"
zsh: segmentation fault (core dumped)  ./*/bin/dice "3d1;4d1;5d1;1d1;ms"

I tried removing the ; before the m. The m operator dosen't do his job

$dice "3;4;5;1ms"
Result: 0 - details:[3;4;5;1ms ()]

At least the d1 version works (but it's obviously what I want to do)

$dice "3d1;4d1;5d1;1d1ms"
Result: 13 - details:[3d1;4d1;5d1;1d1ms (1 1 1 1 1 1 1 1 1 1 1 1 1)]

So I tried to do it with the L dice

$dice "L[3];L[4];L[5];L[1]"
3 ; 4 ; 5 ; 1
$dice "L[3];L[4];L[5];L[1];m"
zsh: segmentation fault (core dumped)  ./*/bin/dice "L[3];L[4];L[5];L[1];m"

But unfortunatly, m don't works with list, it look like

$dice "L[3];L[4];L[5];L[1]m"
1

Btw, I also tried to use parenthesis instead of m, and it's not working as expected

$dice "(3;4;5;1)s"
Result: 3,4,5,1 - details:[(3;4;5;1)s ()]

robinmoussu avatar Jun 02 '18 03:06 robinmoussu

Ideally, the last syntax ((3;4;5;1)ms) is the one I would probably prefer.

In fact I think that I will need at one point a way to specify the full list of all the next rolls, if I want to be able to unit test the reroll and reroll until operator (witch could be only accessible in c++, not necessarily from the cli).

robinmoussu avatar Jun 02 '18 03:06 robinmoussu

I was able to mock the dices (see PR #15), so I don't think this issue is urgent. You may consider close it if you will.

robinmoussu avatar Jun 03 '18 14:06 robinmoussu