Fix #131 - division in enums

This commit is contained in:
Ganesh Viswanathan 2019-07-29 23:24:03 -05:00
commit 29f59eee99
3 changed files with 21 additions and 0 deletions

View file

@ -70,4 +70,9 @@ template defineEnum*(typ) =
proc `xor`*(x: int, y: typ): typ {.borrow.}
proc `xor`*(x, y: typ): typ {.borrow.}
proc `/`(x, y: typ): typ =
return (x.float / y.float).int.typ
proc `/`*(x: typ, y: int): typ = `/`(x, y.typ)
proc `/`*(x: int, y: typ): typ = `/`(x.typ, y)
proc `$` *(x: typ): string {.borrow.}

View file

@ -156,6 +156,16 @@ typedef struct dstruct2 {
void **(*tcv)(int **param1);
} DSTRUCT2;
// Issue #131
enum
{
TDEFL_LZ_CODE_BUF_SIZE = 64 * 1024,
TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13) / 10,
TDEFL_BOGUS_1 = (1024 * 128) / TDEFL_LZ_CODE_BUF_SIZE,
TDEFL_BOGUS_2 = TDEFL_LZ_CODE_BUF_SIZE / 64,
TDEFL_BOGUS_3 = TDEFL_OUT_BUF_SIZE / TDEFL_BOGUS_1
};
#ifdef __cplusplus
}
#endif

View file

@ -172,3 +172,9 @@ ds.field1 = di
ds2.field1 = addr cstr
ds2.tcv = test_call10
check ds2.tcv(di) == nil
# Issue #131
check TDEFL_OUT_BUF_SIZE == 85196
check TDEFL_BOGUS_1 == 2
check TDEFL_BOGUS_2 == 1024
check TDEFL_BOGUS_3 == (85196 / 2).int