Skip to content

Commit

Permalink
Move math cast tests into separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
dkl committed Jan 6, 2021
1 parent 0d8f4ff commit 4cc0291
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 90 deletions.
39 changes: 0 additions & 39 deletions tests/c/expr.bi
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ enum
A = iif(a, b, iif(c, d, e))
A = iif(a, b, iif(c, d, e))
A = iif(iif(a, b, c), d, e)
ENUMCONST1 = 0
end enum

#define A01(x) "a" "b"
Expand Down Expand Up @@ -457,44 +456,6 @@ const A42 = cast(MYINT, 0)
#endmacro
#define A57
#define MAKE_RGB(r, g, b) clng(culng((cbyte(r) or (cushort(cbyte(g)) shl 8)) or culng(culng(cbyte(b)) shl 16)))
const A58 = culng(0u - 100u)
const A59 = culng(0u - 100)
const A60 = 0 - 100
const A61 = culng(0 - 100u)
const A62 = culng(0u - 100u)
const A70 = culng(A58 - 1u)
const A71 = culng(A58 - 1)
const A72 = culng(culng(A58) - 1u)
const A73 = culng(culng(A58) - 1)
const A74 = culng(ENUMCONST1 - 1u)
const A75 = ENUMCONST1 - 1
const A76 = culng(culng(ENUMCONST1) - 1u)
const A77 = culng(culng(ENUMCONST1) - 1)
#define A78 (undefined - 1u)
#define A79 (undefined - 1)
#define A80 culng(culng(undefined) - 1u)
#define A81 culng(culng(undefined) - 1)
#define A82 culng(clng(undefined) - 1u)
#define A83 (clng(undefined) - 1)

#ifdef __FB_WIN32__
#define A84 undefined
#define A85 A84
#else
const A84 = -1
const A85 = A84
#endif

const B00 = culng(0u - 100u)
const B01 = B00
#define B11 culng(B10 - 1)
const B10 = culng(0u - 100u)
#define B22 culng(B21 - 1)
#define B21 culng(B20 - 1)
const B20 = culng(0u - 100u)
#define B31 culng(B30 - 1)
#define B32 culng(B31 - 1)
const B30 = culng(0u - 100u)
#define A90(x) (@(x)->a[(x)->b])

'' TODO: #define A100 struct { int i; }
Expand Down
50 changes: 0 additions & 50 deletions tests/c/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,6 @@ enum E {
A = a ? b : c ? d : e,
A = a ? b : (c ? d : e),
A = (a ? b : c) ? d : e,

ENUMCONST1 = 0,
};

#define A01(x) "a" "b"
Expand Down Expand Up @@ -501,54 +499,6 @@ enum E {
// Testing cast operator precedence
#define MAKE_RGB(r,g,b) ((int)(((signed char)(r)|((unsigned short)((signed char)(g))<<8))|(((unsigned int)(signed char)(b))<<16)))

// A culng() cast needs to be added around this BOP, to ensure the result is
// truncated to 32bit in FB 64bit
#define A58 (0u - 100u)
#define A59 (0u - 100)
#define A60 (0 - 100)
#define A61 (0 - 100u)

// Similar situation here - but the cast is already there, and we shouldn't add
// another one.
#define A62 ((unsigned int)(0u - 100u))

// Expression type depending on the type of an existing symbol
#define A70 (A58 - 1u)
#define A71 (A58 - 1)
#define A72 ((unsigned int) A58 - 1u)
#define A73 ((unsigned int) A58 - 1)
#define A74 (ENUMCONST1 - 1u)
#define A75 (ENUMCONST1 - 1)
#define A76 ((unsigned int)ENUMCONST1 - 1u)
#define A77 ((unsigned int)ENUMCONST1 - 1)
#define A78 (undefined - 1u)
#define A79 (undefined - 1)
#define A80 ((unsigned int)undefined - 1u)
#define A81 ((unsigned int)undefined - 1)
#define A82 ((int)undefined - 1u)
#define A83 ((int)undefined - 1)
#ifdef _WIN32
#define A84 undefined
#else
#define A84 (-1)
#endif
#define A85 A84

// Same but with forward references
#define B01 B00 // simple alias
#define B00 (0u - 100u)

#define B11 (B10 - 1) // "complex" math expression
#define B10 (0u - 100u)

#define B22 (B21 - 1) // extra indirection level
#define B21 (B20 - 1)
#define B20 (0u - 100u)

#define B31 (B30 - 1)
#define B32 (B31 - 1) // isn't a fwdref itself, but refers to one
#define B30 (0u - 100u)

#define A90(x) &(x)->a[(x)->b]

#define A100 struct { int i; }
Expand Down
2 changes: 1 addition & 1 deletion tests/c/expr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
[22/23] cygwin-x86_64
[23/23] dos
tests/c/expr.h
emitting: tests/c/expr.bi (120 declarations, 9 TODOs)
emitting: tests/c/expr.bi (87 declarations, 9 TODOs)
45 changes: 45 additions & 0 deletions tests/highlevel/math-casts.bi
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#pragma once

type E as long
enum
ENUMCONST1 = 0
end enum

const A58 = culng(0u - 100u)
const A59 = culng(0u - 100)
const A60 = 0 - 100
const A61 = culng(0 - 100u)
const A62 = culng(0u - 100u)
const A70 = culng(A58 - 1u)
const A71 = culng(A58 - 1)
const A72 = culng(culng(A58) - 1u)
const A73 = culng(culng(A58) - 1)
const A74 = culng(ENUMCONST1 - 1u)
const A75 = ENUMCONST1 - 1
const A76 = culng(culng(ENUMCONST1) - 1u)
const A77 = culng(culng(ENUMCONST1) - 1)
#define A78 (undefined - 1u)
#define A79 (undefined - 1)
#define A80 culng(culng(undefined) - 1u)
#define A81 culng(culng(undefined) - 1)
#define A82 culng(clng(undefined) - 1u)
#define A83 (clng(undefined) - 1)

#ifdef __FB_WIN32__
#define A84 undefined
#define A85 A84
#else
const A84 = -1
const A85 = A84
#endif

const B00 = culng(0u - 100u)
const B01 = B00
#define B11 culng(B10 - 1)
const B10 = culng(0u - 100u)
#define B22 culng(B21 - 1)
#define B21 culng(B20 - 1)
const B20 = culng(0u - 100u)
#define B31 culng(B30 - 1)
#define B32 culng(B31 - 1)
const B30 = culng(0u - 100u)
51 changes: 51 additions & 0 deletions tests/highlevel/math-casts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
enum E {
ENUMCONST1 = 0,
};

// A culng() cast needs to be added around this BOP, to ensure the result is
// truncated to 32bit in FB 64bit
#define A58 (0u - 100u)
#define A59 (0u - 100)
#define A60 (0 - 100)
#define A61 (0 - 100u)

// Similar situation here - but the cast is already there, and we shouldn't add
// another one.
#define A62 ((unsigned int)(0u - 100u))

// Expression type depending on the type of an existing symbol
#define A70 (A58 - 1u)
#define A71 (A58 - 1)
#define A72 ((unsigned int) A58 - 1u)
#define A73 ((unsigned int) A58 - 1)
#define A74 (ENUMCONST1 - 1u)
#define A75 (ENUMCONST1 - 1)
#define A76 ((unsigned int)ENUMCONST1 - 1u)
#define A77 ((unsigned int)ENUMCONST1 - 1)
#define A78 (undefined - 1u)
#define A79 (undefined - 1)
#define A80 ((unsigned int)undefined - 1u)
#define A81 ((unsigned int)undefined - 1)
#define A82 ((int)undefined - 1u)
#define A83 ((int)undefined - 1)
#ifdef _WIN32
#define A84 undefined
#else
#define A84 (-1)
#endif
#define A85 A84

// Same but with forward references
#define B01 B00 // simple alias
#define B00 (0u - 100u)

#define B11 (B10 - 1) // "complex" math expression
#define B10 (0u - 100u)

#define B22 (B21 - 1) // extra indirection level
#define B21 (B20 - 1)
#define B20 (0u - 100u)

#define B31 (B30 - 1)
#define B32 (B31 - 1) // isn't a fwdref itself, but refers to one
#define B30 (0u - 100u)
25 changes: 25 additions & 0 deletions tests/highlevel/math-casts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[ 1/23] linux-x86
[ 2/23] linux-x86_64
[ 3/23] linux-arm
[ 4/23] linux-aarch64
[ 5/23] freebsd-x86
[ 6/23] freebsd-x86_64
[ 7/23] freebsd-arm
[ 8/23] freebsd-aarch64
[ 9/23] openbsd-x86
[10/23] openbsd-x86_64
[11/23] openbsd-arm
[12/23] openbsd-aarch64
[13/23] netbsd-x86
[14/23] netbsd-x86_64
[15/23] netbsd-arm
[16/23] netbsd-aarch64
[17/23] darwin-x86
[18/23] darwin-x86_64
[19/23] win32
[20/23] win64
[21/23] cygwin-x86
[22/23] cygwin-x86_64
[23/23] dos
tests/highlevel/math-casts.h
emitting: tests/highlevel/math-casts.bi (34 declarations, 0 TODOs)

0 comments on commit 4cc0291

Please sign in to comment.