mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-14 08:45:28 +00:00
Merge branch 'master' into windows-llvm-13.0.0
This commit is contained in:
12
.github/workflows/ci.yml
vendored
12
.github/workflows/ci.yml
vendored
@@ -38,11 +38,6 @@ jobs:
|
||||
cd tests/vendor
|
||||
make
|
||||
timeout-minutes: 10
|
||||
- name: Odin issues tests
|
||||
run: |
|
||||
cd tests/issues
|
||||
./run.sh
|
||||
timeout-minutes: 10
|
||||
- name: Odin check examples/all for Linux i386
|
||||
run: ./odin check examples/all -vet -strict-style -target:linux_i386
|
||||
timeout-minutes: 10
|
||||
@@ -163,13 +158,6 @@ jobs:
|
||||
cd tests\core\math\big
|
||||
call build.bat
|
||||
timeout-minutes: 10
|
||||
- name: Odin issues tests
|
||||
shell: cmd
|
||||
run: |
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat
|
||||
cd tests\issues
|
||||
call run.bat
|
||||
timeout-minutes: 10
|
||||
- name: Odin check examples/all for Windows 32bits
|
||||
shell: cmd
|
||||
run: |
|
||||
|
||||
2
.github/workflows/nightly.yml
vendored
2
.github/workflows/nightly.yml
vendored
@@ -50,7 +50,7 @@ jobs:
|
||||
run: |
|
||||
mkdir dist
|
||||
cp odin dist
|
||||
cp libLLVM*.so dist
|
||||
cp libLLVM* dist
|
||||
cp -r shared dist
|
||||
cp -r core dist
|
||||
cp -r vendor dist
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -271,7 +271,7 @@ odin
|
||||
odin.dSYM
|
||||
*.bin
|
||||
demo.bin
|
||||
libLLVM*.so
|
||||
libLLVM*.so*
|
||||
|
||||
# shared collection
|
||||
shared/
|
||||
|
||||
@@ -100,7 +100,11 @@ config_linux() {
|
||||
LDFLAGS="$LDFLAGS -ldl"
|
||||
CXXFLAGS="$CXXFLAGS $($LLVM_CONFIG --cxxflags --ldflags)"
|
||||
LDFLAGS="$LDFLAGS $($LLVM_CONFIG --libs core native --system-libs --libfiles) -Wl,-rpath=\$ORIGIN"
|
||||
cp $($LLVM_CONFIG --libfiles) ./
|
||||
|
||||
# Creates a copy of the llvm library in the build dir, this is meant to support compiler explorer.
|
||||
# The annoyance is that this copy can be cluttering the development folder. TODO: split staging folders
|
||||
# for development and compiler explorer builds
|
||||
cp $(readlink -f $($LLVM_CONFIG --libfiles)) ./
|
||||
}
|
||||
|
||||
build_odin() {
|
||||
|
||||
@@ -240,14 +240,11 @@ buffer_read_ptr :: proc(b: ^Buffer, ptr: rawptr, size: int) -> (n: int, err: io.
|
||||
buffer_read_at :: proc(b: ^Buffer, p: []byte, offset: int) -> (n: int, err: io.Error) {
|
||||
b.last_read = .Invalid
|
||||
|
||||
if offset < 0 || offset >= len(b.buf) {
|
||||
if uint(offset) >= len(b.buf) {
|
||||
err = .Invalid_Offset
|
||||
return
|
||||
}
|
||||
|
||||
if 0 <= offset && offset < len(b.buf) {
|
||||
n = copy(p, b.buf[offset:])
|
||||
}
|
||||
n = copy(p, b.buf[offset:])
|
||||
if n > 0 {
|
||||
b.last_read = .Read
|
||||
}
|
||||
|
||||
@@ -638,7 +638,7 @@ trim_left_proc :: proc(s: []byte, p: proc(rune) -> bool) -> []byte {
|
||||
|
||||
index_rune :: proc(s: []byte, r: rune) -> int {
|
||||
switch {
|
||||
case 0 <= r && r < utf8.RUNE_SELF:
|
||||
case u32(r) < utf8.RUNE_SELF:
|
||||
return index_byte(s, byte(r))
|
||||
|
||||
case r == utf8.RUNE_ERROR:
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package libc
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import libc "system:libucrt.lib"
|
||||
foreign import libc {
|
||||
"system:libucrt.lib",
|
||||
"system:legacy_stdio_definitions.lib",
|
||||
}
|
||||
} else when ODIN_OS == .Darwin {
|
||||
foreign import libc "system:System.framework"
|
||||
} else {
|
||||
|
||||
@@ -380,20 +380,18 @@ unmarshal_object :: proc(p: ^Parser, v: any, end_token: Token_Kind) -> (err: Unm
|
||||
field := any{field_ptr, type.id}
|
||||
unmarshal_value(p, field) or_return
|
||||
|
||||
if parse_comma(p) {
|
||||
break struct_loop
|
||||
}
|
||||
continue struct_loop
|
||||
} else {
|
||||
// allows skipping unused struct fields
|
||||
parse_value(p) or_return
|
||||
if parse_comma(p) {
|
||||
break struct_loop
|
||||
}
|
||||
continue struct_loop
|
||||
}
|
||||
|
||||
// NOTE(bill, 2022-09-14): Previously this would not be allowed
|
||||
// {"foo": 123, "bar": 456}
|
||||
// T :: struct{foo: int}
|
||||
// `T` is missing the `bar` field
|
||||
// The line below is commented out to ignore fields in an object which
|
||||
// do not have a corresponding target field
|
||||
//
|
||||
// return Unsupported_Type_Error{v.id, p.curr_token}
|
||||
}
|
||||
|
||||
case reflect.Type_Info_Map:
|
||||
|
||||
@@ -76,8 +76,7 @@ growing_arena_destroy :: proc(arena: ^Growing_Arena) {
|
||||
growing_arena_free_all(arena)
|
||||
}
|
||||
|
||||
growing_arena_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintptr, minimum_block_size := DEFAULT_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) {
|
||||
bootstrap: Growing_Arena
|
||||
growing_arena_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintptr, minimum_block_size: uint = DEFAULT_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) { bootstrap: Growing_Arena
|
||||
bootstrap.minimum_block_size = minimum_block_size
|
||||
|
||||
data := growing_arena_alloc(&bootstrap, size_of(T), align_of(T)) or_return
|
||||
@@ -89,7 +88,7 @@ growing_arena_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintp
|
||||
return
|
||||
}
|
||||
|
||||
growing_arena_bootstrap_new_by_name :: proc($T: typeid, $field_name: string, minimum_block_size := DEFAULT_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) {
|
||||
growing_arena_bootstrap_new_by_name :: proc($T: typeid, $field_name: string, minimum_block_size: uint = DEFAULT_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) {
|
||||
return growing_arena_bootstrap_new_by_offset(T, offset_of_by_string(T, field_name), minimum_block_size)
|
||||
}
|
||||
growing_arena_bootstrap_new :: proc{
|
||||
|
||||
@@ -369,27 +369,45 @@ close :: proc(fd: Handle) -> bool {
|
||||
return _unix_close(fd) == 0
|
||||
}
|
||||
|
||||
@(private)
|
||||
MAX_RW :: 0x7fffffff // The limit on Darwin is max(i32), trying to read/write more than that fails.
|
||||
|
||||
write :: proc(fd: Handle, data: []u8) -> (int, Errno) {
|
||||
assert(fd != -1)
|
||||
|
||||
if len(data) == 0 {
|
||||
return 0, 0
|
||||
bytes_total := len(data)
|
||||
bytes_written_total := 0
|
||||
|
||||
for bytes_written_total < bytes_total {
|
||||
bytes_to_write := min(bytes_total - bytes_written_total, MAX_RW)
|
||||
slice := data[bytes_written_total:bytes_written_total + bytes_to_write]
|
||||
bytes_written := _unix_write(fd, raw_data(slice), bytes_to_write)
|
||||
if bytes_written == -1 {
|
||||
return bytes_written_total, 1
|
||||
}
|
||||
bytes_written_total += bytes_written
|
||||
}
|
||||
bytes_written := _unix_write(fd, raw_data(data), len(data))
|
||||
if bytes_written == -1 {
|
||||
return 0, 1
|
||||
}
|
||||
return bytes_written, 0
|
||||
|
||||
return bytes_written_total, 0
|
||||
}
|
||||
|
||||
read :: proc(fd: Handle, data: []u8) -> (int, Errno) {
|
||||
assert(fd != -1)
|
||||
|
||||
bytes_read := _unix_read(fd, raw_data(data), len(data))
|
||||
if bytes_read == -1 {
|
||||
return 0, 1
|
||||
bytes_total := len(data)
|
||||
bytes_read_total := 0
|
||||
|
||||
for bytes_read_total < bytes_total {
|
||||
bytes_to_read := min(bytes_total - bytes_read_total, MAX_RW)
|
||||
slice := data[bytes_read_total:bytes_read_total + bytes_to_read]
|
||||
bytes_read := _unix_read(fd, raw_data(slice), bytes_to_read)
|
||||
if bytes_read == -1 {
|
||||
return bytes_read_total, 1
|
||||
}
|
||||
bytes_read_total += bytes_read
|
||||
}
|
||||
return bytes_read, 0
|
||||
|
||||
return bytes_read_total, 0
|
||||
}
|
||||
|
||||
seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Errno) {
|
||||
|
||||
@@ -18,7 +18,7 @@ type_assertion_trap :: proc "contextless" () -> ! {
|
||||
|
||||
|
||||
bounds_check_error :: proc "contextless" (file: string, line, column: i32, index, count: int) {
|
||||
if 0 <= index && index < count {
|
||||
if uint(index) < uint(count) {
|
||||
return
|
||||
}
|
||||
@(cold)
|
||||
@@ -99,8 +99,8 @@ dynamic_array_expr_error :: proc "contextless" (file: string, line, column: i32,
|
||||
|
||||
|
||||
matrix_bounds_check_error :: proc "contextless" (file: string, line, column: i32, row_index, column_index, row_count, column_count: int) {
|
||||
if 0 <= row_index && row_index < row_count &&
|
||||
0 <= column_index && column_index < column_count {
|
||||
if uint(row_index) < uint(row_count) &&
|
||||
uint(column_index) < uint(column_count) {
|
||||
return
|
||||
}
|
||||
@(cold)
|
||||
|
||||
@@ -321,14 +321,14 @@ last_ptr :: proc(array: $T/[]$E) -> ^E {
|
||||
}
|
||||
|
||||
get :: proc(array: $T/[]$E, index: int) -> (value: E, ok: bool) {
|
||||
if 0 <= index && index < len(array) {
|
||||
if uint(index) < len(array) {
|
||||
value = array[index]
|
||||
ok = true
|
||||
}
|
||||
return
|
||||
}
|
||||
get_ptr :: proc(array: $T/[]$E, index: int) -> (value: ^E, ok: bool) {
|
||||
if 0 <= index && index < len(array) {
|
||||
if uint(index) < len(array) {
|
||||
value = &array[index]
|
||||
ok = true
|
||||
}
|
||||
|
||||
@@ -567,7 +567,7 @@ parse_f32 :: proc(s: string, n: ^int = nil) -> (value: f32, ok: bool) {
|
||||
// ```
|
||||
parse_f64 :: proc(str: string, n: ^int = nil) -> (value: f64, ok: bool) {
|
||||
s := str
|
||||
defer if n != nil { n^ = len(str)-len(s) }
|
||||
defer if n != nil { n^ = len(str) - len(s) }
|
||||
if s == "" {
|
||||
return
|
||||
}
|
||||
@@ -588,6 +588,38 @@ parse_f64 :: proc(str: string, n: ^int = nil) -> (value: f64, ok: bool) {
|
||||
|
||||
v := _digit_value(r)
|
||||
if v >= 10 {
|
||||
if r == '.' || r == 'e' || r == 'E' { // Skip parsing NaN and Inf if it's probably a regular float
|
||||
break
|
||||
}
|
||||
if len(s) >= 3 + i {
|
||||
buf: [4]u8
|
||||
copy(buf[:], s[i:][:3])
|
||||
|
||||
v2 := transmute(u32)buf
|
||||
v2 &= 0xDFDFDFDF // Knock out lower-case bits
|
||||
|
||||
buf = transmute([4]u8)v2
|
||||
|
||||
when ODIN_ENDIAN == .Little {
|
||||
if v2 == 0x464e49 { // "INF"
|
||||
s = s[3+i:]
|
||||
value = 0h7ff00000_00000000 if sign == 1 else 0hfff00000_00000000
|
||||
return value, len(s) == 0
|
||||
} else if v2 == 0x4e414e { // "NAN"
|
||||
s = s[3+i:]
|
||||
return 0h7ff80000_00000001, len(s) == 0
|
||||
}
|
||||
} else {
|
||||
if v2 == 0x494e4600 { // "\0FNI"
|
||||
s = s[3+i:]
|
||||
value = 0h7ff00000_00000000 if sign == 1 else 0hfff00000_00000000
|
||||
return value, len(s) == 0
|
||||
} else if v2 == 0x4e414e00 { // "\0NAN"
|
||||
s = s[3+i:]
|
||||
return 0h7ff80000_00000001, len(s) == 0
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
value *= 10
|
||||
|
||||
@@ -760,7 +760,7 @@ last_index_byte :: proc(s: string, c: byte) -> int {
|
||||
*/
|
||||
index_rune :: proc(s: string, r: rune) -> int {
|
||||
switch {
|
||||
case 0 <= r && r < utf8.RUNE_SELF:
|
||||
case u32(r) < utf8.RUNE_SELF:
|
||||
return index_byte(s, byte(r))
|
||||
|
||||
case r == utf8.RUNE_ERROR:
|
||||
|
||||
@@ -464,6 +464,7 @@ macos_release_map: map[string]Darwin_To_Release = {
|
||||
"21F2092" = {{21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}},
|
||||
"21G72" = {{21, 6, 0}, "macOS", {"Monterey", {12, 5, 0}}},
|
||||
"21G83" = {{21, 6, 0}, "macOS", {"Monterey", {12, 5, 1}}},
|
||||
"21G115" = {{21, 6, 0}, "macOS", {"Monterey", {12, 6, 0}}},
|
||||
}
|
||||
|
||||
@(private)
|
||||
|
||||
@@ -963,4 +963,15 @@ DCB :: struct {
|
||||
foreign kernel32 {
|
||||
GetCommState :: proc(handle: HANDLE, dcb: ^DCB) -> BOOL ---
|
||||
SetCommState :: proc(handle: HANDLE, dcb: ^DCB) -> BOOL ---
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LPFIBER_START_ROUTINE :: #type proc "stdcall" (lpFiberParameter: LPVOID)
|
||||
|
||||
@(default_calling_convention = "stdcall")
|
||||
foreign kernel32 {
|
||||
CreateFiber :: proc(dwStackSize: SIZE_T, lpStartAddress: LPFIBER_START_ROUTINE, lpParameter: LPVOID) -> LPVOID ---
|
||||
DeleteFiber :: proc(lpFiber: LPVOID) ---
|
||||
ConvertThreadToFiber :: proc(lpParameter: LPVOID) -> LPVOID ---
|
||||
SwitchToFiber :: proc(lpFiber: LPVOID) ---
|
||||
}
|
||||
|
||||
@@ -1662,6 +1662,7 @@ WSAENOTCONN: c_int : 10057
|
||||
WSAESHUTDOWN: c_int : 10058
|
||||
WSAETIMEDOUT: c_int : 10060
|
||||
WSAECONNREFUSED: c_int : 10061
|
||||
WSATRY_AGAIN: c_int : 11002
|
||||
|
||||
MAX_PROTOCOL_CHAIN: DWORD : 7
|
||||
|
||||
|
||||
@@ -104,6 +104,9 @@ foreign user32 {
|
||||
GetDC :: proc(hWnd: HWND) -> HDC ---
|
||||
ReleaseDC :: proc(hWnd: HWND, hDC: HDC) -> c_int ---
|
||||
|
||||
GetDlgCtrlID :: proc(hWnd: HWND) -> c_int ---
|
||||
GetDlgItem :: proc(hDlg: HWND, nIDDlgItem: c_int) -> HWND ---
|
||||
|
||||
GetUpdateRect :: proc(hWnd: HWND, lpRect: LPRECT, bErase: BOOL) -> BOOL ---
|
||||
ValidateRect :: proc(hWnd: HWND, lpRect: ^RECT) -> BOOL ---
|
||||
InvalidateRect :: proc(hWnd: HWND, lpRect: ^RECT, bErase: BOOL) -> BOOL ---
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,15 +2,13 @@
|
||||
|
||||
if not exist "build\" mkdir build
|
||||
|
||||
set COMMON=-collection:tests=.. -out:build\test_issue.exe
|
||||
set COMMON=-collection:tests=..
|
||||
|
||||
@echo on
|
||||
|
||||
..\..\odin build test_issue_829.odin %COMMON% -file
|
||||
build\test_issue
|
||||
|
||||
..\..\odin build test_issue_1592.odin %COMMON% -file
|
||||
build\test_issue
|
||||
..\..\odin test test_issue_829.odin %COMMON% -file
|
||||
..\..\odin test test_issue_1592.odin %COMMON% -file
|
||||
..\..\odin test test_issue_2087.odin %COMMON% -file
|
||||
|
||||
@echo off
|
||||
|
||||
|
||||
@@ -3,15 +3,13 @@ set -eu
|
||||
|
||||
mkdir -p build
|
||||
ODIN=../../odin
|
||||
COMMON="-collection:tests=.. -out:build/test_issue"
|
||||
COMMON="-collection:tests=.."
|
||||
|
||||
set -x
|
||||
|
||||
$ODIN build test_issue_829.odin $COMMON -file
|
||||
./build/test_issue
|
||||
|
||||
$ODIN build test_issue_1592.odin $COMMON -file
|
||||
./build/test_issue
|
||||
$ODIN test test_issue_829.odin $COMMON -file
|
||||
$ODIN test test_issue_1592.odin $COMMON -file
|
||||
$ODIN test test_issue_2087.odin $COMMON -file
|
||||
|
||||
set +x
|
||||
|
||||
|
||||
@@ -3,36 +3,6 @@ package test_issues
|
||||
|
||||
import "core:fmt"
|
||||
import "core:testing"
|
||||
import tc "tests:common"
|
||||
|
||||
main :: proc() {
|
||||
t := testing.T{}
|
||||
|
||||
/* This won't short-circuit */
|
||||
test_orig()
|
||||
|
||||
/* These will short-circuit */
|
||||
test_simple_const_false(&t)
|
||||
test_simple_const_true(&t)
|
||||
|
||||
/* These won't short-circuit */
|
||||
test_simple_proc_false(&t)
|
||||
test_simple_proc_true(&t)
|
||||
|
||||
/* These won't short-circuit */
|
||||
test_const_false_const_false(&t)
|
||||
test_const_false_const_true(&t)
|
||||
test_const_true_const_false(&t)
|
||||
test_const_true_const_true(&t)
|
||||
|
||||
/* These won't short-circuit */
|
||||
test_proc_false_const_false(&t)
|
||||
test_proc_false_const_true(&t)
|
||||
test_proc_true_const_false(&t)
|
||||
test_proc_true_const_true(&t)
|
||||
|
||||
tc.report(&t)
|
||||
}
|
||||
|
||||
/* Original issue #1592 example */
|
||||
|
||||
@@ -43,7 +13,6 @@ bool_result :: proc() -> bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@test
|
||||
test_orig :: proc() {
|
||||
if bool_result() || CONSTANT_BOOL {
|
||||
}
|
||||
@@ -62,428 +31,428 @@ true_result :: proc() -> bool {
|
||||
@test
|
||||
test_simple_const_false :: proc(t: ^testing.T) {
|
||||
if CONSTANT_FALSE {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if (CONSTANT_FALSE) {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if !CONSTANT_FALSE {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if (!CONSTANT_FALSE) {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if !(CONSTANT_FALSE) {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if !!CONSTANT_FALSE {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if CONSTANT_FALSE == true {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if CONSTANT_FALSE == false {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if !(CONSTANT_FALSE == true) {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if !(CONSTANT_FALSE == false) {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
}
|
||||
|
||||
@test
|
||||
test_simple_const_true :: proc(t: ^testing.T) {
|
||||
if CONSTANT_TRUE {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if (CONSTANT_TRUE) {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if !CONSTANT_TRUE {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if (!CONSTANT_TRUE) {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if (!CONSTANT_TRUE) {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if !(CONSTANT_TRUE) {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if !!CONSTANT_TRUE {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if CONSTANT_TRUE == true {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if CONSTANT_TRUE == false {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if !(CONSTANT_TRUE == true) {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if !(CONSTANT_TRUE == false) {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
}
|
||||
|
||||
@test
|
||||
test_simple_proc_false :: proc(t: ^testing.T) {
|
||||
if false_result() {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if !false_result() {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
}
|
||||
|
||||
@test
|
||||
test_simple_proc_true :: proc(t: ^testing.T) {
|
||||
if true_result() {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if !true_result() {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
}
|
||||
|
||||
@test
|
||||
test_const_false_const_false :: proc(t: ^testing.T) {
|
||||
if CONSTANT_FALSE || CONSTANT_FALSE {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if CONSTANT_FALSE && CONSTANT_FALSE {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
|
||||
if !CONSTANT_FALSE || CONSTANT_FALSE {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if !CONSTANT_FALSE && CONSTANT_FALSE {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
|
||||
if CONSTANT_FALSE || !CONSTANT_FALSE {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if CONSTANT_FALSE && !CONSTANT_FALSE {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
|
||||
if !(CONSTANT_FALSE || CONSTANT_FALSE) {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if !(CONSTANT_FALSE && CONSTANT_FALSE) {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
}
|
||||
|
||||
@test
|
||||
test_const_false_const_true :: proc(t: ^testing.T) {
|
||||
if CONSTANT_FALSE || CONSTANT_TRUE {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if CONSTANT_FALSE && CONSTANT_TRUE {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
|
||||
if !CONSTANT_FALSE || CONSTANT_TRUE {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if !CONSTANT_FALSE && CONSTANT_TRUE {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
|
||||
if CONSTANT_FALSE || !CONSTANT_TRUE {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if CONSTANT_FALSE && !CONSTANT_TRUE {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
|
||||
if !(CONSTANT_FALSE || CONSTANT_TRUE) {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if !(CONSTANT_FALSE && CONSTANT_TRUE) {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
}
|
||||
|
||||
@test
|
||||
test_const_true_const_false :: proc(t: ^testing.T) {
|
||||
if CONSTANT_TRUE || CONSTANT_FALSE {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if CONSTANT_TRUE && CONSTANT_FALSE {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
|
||||
if !CONSTANT_TRUE || CONSTANT_FALSE {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if !CONSTANT_TRUE && CONSTANT_FALSE {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
|
||||
if CONSTANT_TRUE || !CONSTANT_FALSE {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if CONSTANT_TRUE && !CONSTANT_FALSE {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
|
||||
if !(CONSTANT_TRUE || CONSTANT_FALSE) {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if !(CONSTANT_TRUE && CONSTANT_FALSE) {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
}
|
||||
|
||||
@test
|
||||
test_const_true_const_true :: proc(t: ^testing.T) {
|
||||
if CONSTANT_TRUE || CONSTANT_TRUE {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if CONSTANT_TRUE && CONSTANT_TRUE {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
|
||||
if !CONSTANT_TRUE || CONSTANT_TRUE {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if !CONSTANT_TRUE && CONSTANT_TRUE {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
|
||||
if CONSTANT_TRUE || !CONSTANT_TRUE {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if CONSTANT_TRUE && !CONSTANT_TRUE {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
|
||||
if !(CONSTANT_TRUE || CONSTANT_TRUE) {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if !(CONSTANT_TRUE && CONSTANT_TRUE) {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
}
|
||||
|
||||
@test
|
||||
test_proc_false_const_false :: proc(t: ^testing.T) {
|
||||
if false_result() || CONSTANT_FALSE {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if false_result() && CONSTANT_FALSE {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
|
||||
if !(false_result() || CONSTANT_FALSE) {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if !(false_result() && CONSTANT_FALSE) {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
}
|
||||
|
||||
@test
|
||||
test_proc_false_const_true :: proc(t: ^testing.T) {
|
||||
if false_result() || CONSTANT_TRUE {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if false_result() && CONSTANT_TRUE {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
|
||||
if !(false_result() || CONSTANT_TRUE) {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if !(false_result() && CONSTANT_TRUE) {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
}
|
||||
|
||||
@test
|
||||
test_proc_true_const_false :: proc(t: ^testing.T) {
|
||||
if true_result() || CONSTANT_FALSE {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if true_result() && CONSTANT_FALSE {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
|
||||
if !(true_result() || CONSTANT_FALSE) {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if !(true_result() && CONSTANT_FALSE) {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
}
|
||||
|
||||
@test
|
||||
test_proc_true_const_true :: proc(t: ^testing.T) {
|
||||
if true_result() || CONSTANT_TRUE {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
if true_result() && CONSTANT_TRUE {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
}
|
||||
|
||||
if !(true_result() || CONSTANT_TRUE) {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
if !(true_result() && CONSTANT_TRUE) {
|
||||
tc.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure))
|
||||
} else {
|
||||
tc.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure))
|
||||
}
|
||||
}
|
||||
|
||||
58
tests/issues/test_issue_2087.odin
Normal file
58
tests/issues/test_issue_2087.odin
Normal file
@@ -0,0 +1,58 @@
|
||||
// Tests issue #2087 https://github.com/odin-lang/Odin/issues/2087
|
||||
package test_issues
|
||||
|
||||
import "core:math"
|
||||
import "core:strconv"
|
||||
import "core:testing"
|
||||
|
||||
@(test)
|
||||
test_parse_float :: proc(t: ^testing.T) {
|
||||
{
|
||||
f, ok := strconv.parse_f64("1.2")
|
||||
testing.expect(t, ok && f == 1.2, "expected f64(1.2), fully consumed")
|
||||
|
||||
f, ok = strconv.parse_f64("1.2a")
|
||||
testing.expect(t, !ok && f == 1.2, "expected f64(1.2), partially consumed")
|
||||
|
||||
f, ok = strconv.parse_f64("inf")
|
||||
testing.expect(t, ok && math.classify(f) == math.Float_Class.Inf, "expected f64(+inf), fully consumed")
|
||||
f, ok = strconv.parse_f64("+inf")
|
||||
testing.expect(t, ok && math.classify(f) == math.Float_Class.Inf, "expected f64(+inf), fully consumed")
|
||||
f, ok = strconv.parse_f64("-inf")
|
||||
testing.expect(t, ok && math.classify(f) == math.Float_Class.Neg_Inf, "expected f64(-inf), fully consumed")
|
||||
f, ok = strconv.parse_f64("inFinity")
|
||||
testing.expect(t, !ok && math.classify(f) == math.Float_Class.Inf, "expected f64(+inf), partially consumed")
|
||||
f, ok = strconv.parse_f64("+InFinity")
|
||||
testing.expect(t, !ok && math.classify(f) == math.Float_Class.Inf, "expected f64(+inf), partially consumed")
|
||||
f, ok = strconv.parse_f64("-InfiniTy")
|
||||
testing.expect(t, !ok && math.classify(f) == math.Float_Class.Neg_Inf, "expected f64(-inf), partially consumed")
|
||||
f, ok = strconv.parse_f64("nan")
|
||||
testing.expect(t, ok && math.classify(f) == math.Float_Class.NaN, "expected f64(nan), fully consumed")
|
||||
f, ok = strconv.parse_f64("nAN")
|
||||
testing.expect(t, ok && math.classify(f) == math.Float_Class.NaN, "expected f64(nan), fully consumed")
|
||||
}
|
||||
{
|
||||
f, ok := strconv.parse_f32("1.2")
|
||||
testing.expect(t, ok && f == 1.2, "expected f32(1.2), fully consumed")
|
||||
|
||||
f, ok = strconv.parse_f32("1.2a")
|
||||
testing.expect(t, !ok && f == 1.2, "expected f32(1.2), partially consumed")
|
||||
|
||||
f, ok = strconv.parse_f32("inf")
|
||||
testing.expect(t, ok && math.classify(f) == math.Float_Class.Inf, "expected f32(+inf), fully consumed")
|
||||
f, ok = strconv.parse_f32("+inf")
|
||||
testing.expect(t, ok && math.classify(f) == math.Float_Class.Inf, "expected f32(+inf), fully consumed")
|
||||
f, ok = strconv.parse_f32("-inf")
|
||||
testing.expect(t, ok && math.classify(f) == math.Float_Class.Neg_Inf, "expected f32(-inf), fully consumed")
|
||||
f, ok = strconv.parse_f32("inFinity")
|
||||
testing.expect(t, !ok && math.classify(f) == math.Float_Class.Inf, "expected f32(+inf), partially consumed")
|
||||
f, ok = strconv.parse_f32("+InFinity")
|
||||
testing.expect(t, !ok && math.classify(f) == math.Float_Class.Inf, "expected f32(+inf), partially consumed")
|
||||
f, ok = strconv.parse_f32("-InfiniTy")
|
||||
testing.expect(t, !ok && math.classify(f) == math.Float_Class.Neg_Inf, "expected f32(-inf), partially consumed")
|
||||
f, ok = strconv.parse_f32("nan")
|
||||
testing.expect(t, ok && math.classify(f) == math.Float_Class.NaN, "expected f32(nan), fully consumed")
|
||||
f, ok = strconv.parse_f32("nAN")
|
||||
testing.expect(t, ok && math.classify(f) == math.Float_Class.NaN, "expected f32(nan), fully consumed")
|
||||
}
|
||||
}
|
||||
@@ -3,31 +3,16 @@ package test_issues
|
||||
|
||||
import "core:fmt"
|
||||
import "core:testing"
|
||||
import tc "tests:common"
|
||||
|
||||
/* Original issue #829 example */
|
||||
|
||||
env : map[string]proc(a, b : int) -> int = {
|
||||
"+" = proc(a, b : int) -> int {
|
||||
return a + b
|
||||
},
|
||||
}
|
||||
|
||||
test_orig :: proc() {
|
||||
fmt.println(env["+"](1, 2))
|
||||
}
|
||||
|
||||
main :: proc() {
|
||||
t := testing.T{}
|
||||
|
||||
test_orig()
|
||||
|
||||
test_orig_ret(&t)
|
||||
|
||||
tc.report(&t)
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_orig_ret :: proc(t: ^testing.T) {
|
||||
r := fmt.tprint(env["+"](1, 2))
|
||||
tc.expect(t, r == "3", fmt.tprintf("%s: \"%s\" != \"3\"\n", #procedure, r))
|
||||
testing.expect(t, r == "3", fmt.tprintf("%s: \"%s\" != \"3\"\n", #procedure, r))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user