mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-23 14:14:59 -07:00
Remove using where easily possible
This commit is contained in:
@@ -21,16 +21,13 @@ main :: proc() {
|
||||
|
||||
@test
|
||||
test_read :: proc(t: ^testing.T) {
|
||||
|
||||
using hxa
|
||||
|
||||
filename := tc.get_data_path(t, TEAPOT_PATH)
|
||||
defer delete(filename)
|
||||
|
||||
file, err := read_from_file(filename)
|
||||
file, err := hxa.read_from_file(filename)
|
||||
e :: hxa.Read_Error.None
|
||||
tc.expect(t, err == e, fmt.tprintf("%v: read_from_file(%v) -> %v != %v", #procedure, filename, err, e))
|
||||
defer file_destroy(file)
|
||||
defer hxa.file_destroy(file)
|
||||
|
||||
/* Header */
|
||||
tc.expect(t, file.magic_number == 0x417848, fmt.tprintf("%v: file.magic_number %v != %v",
|
||||
|
||||
@@ -214,43 +214,40 @@ doc_to_string :: proc(doc: ^xml.Document) -> (result: string) {
|
||||
*/
|
||||
print :: proc(writer: io.Writer, doc: ^xml.Document) -> (written: int, err: io.Error) {
|
||||
if doc == nil { return }
|
||||
using fmt
|
||||
|
||||
written += wprintf(writer, "[XML Prolog]\n")
|
||||
written += fmt.wprintf(writer, "[XML Prolog]\n")
|
||||
|
||||
for attr in doc.prologue {
|
||||
written += wprintf(writer, "\t%v: %v\n", attr.key, attr.val)
|
||||
written += fmt.wprintf(writer, "\t%v: %v\n", attr.key, attr.val)
|
||||
}
|
||||
|
||||
written += wprintf(writer, "[Encoding] %v\n", doc.encoding)
|
||||
written += fmt.wprintf(writer, "[Encoding] %v\n", doc.encoding)
|
||||
|
||||
if len(doc.doctype.ident) > 0 {
|
||||
written += wprintf(writer, "[DOCTYPE] %v\n", doc.doctype.ident)
|
||||
written += fmt.wprintf(writer, "[DOCTYPE] %v\n", doc.doctype.ident)
|
||||
|
||||
if len(doc.doctype.rest) > 0 {
|
||||
wprintf(writer, "\t%v\n", doc.doctype.rest)
|
||||
fmt.wprintf(writer, "\t%v\n", doc.doctype.rest)
|
||||
}
|
||||
}
|
||||
|
||||
for comment in doc.comments {
|
||||
written += wprintf(writer, "[Pre-root comment] %v\n", comment)
|
||||
written += fmt.wprintf(writer, "[Pre-root comment] %v\n", comment)
|
||||
}
|
||||
|
||||
if doc.element_count > 0 {
|
||||
wprintln(writer, " --- ")
|
||||
fmt.wprintln(writer, " --- ")
|
||||
print_element(writer, doc, 0)
|
||||
wprintln(writer, " --- ")
|
||||
fmt.wprintln(writer, " --- ")
|
||||
}
|
||||
|
||||
return written, .None
|
||||
}
|
||||
|
||||
print_element :: proc(writer: io.Writer, doc: ^xml.Document, element_id: xml.Element_ID, indent := 0) -> (written: int, err: io.Error) {
|
||||
using fmt
|
||||
|
||||
tab :: proc(writer: io.Writer, indent: int) {
|
||||
for _ in 0..=indent {
|
||||
wprintf(writer, "\t")
|
||||
fmt.wprintf(writer, "\t")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,13 +256,13 @@ doc_to_string :: proc(doc: ^xml.Document) -> (result: string) {
|
||||
element := doc.elements[element_id]
|
||||
|
||||
if element.kind == .Element {
|
||||
wprintf(writer, "<%v>\n", element.ident)
|
||||
fmt.wprintf(writer, "<%v>\n", element.ident)
|
||||
|
||||
for value in element.value {
|
||||
switch v in value {
|
||||
case string:
|
||||
tab(writer, indent + 1)
|
||||
wprintf(writer, "[Value] %v\n", v)
|
||||
fmt.wprintf(writer, "[Value] %v\n", v)
|
||||
case xml.Element_ID:
|
||||
print_element(writer, doc, v, indent + 1)
|
||||
}
|
||||
@@ -273,10 +270,10 @@ doc_to_string :: proc(doc: ^xml.Document) -> (result: string) {
|
||||
|
||||
for attr in element.attribs {
|
||||
tab(writer, indent + 1)
|
||||
wprintf(writer, "[Attr] %v: %v\n", attr.key, attr.val)
|
||||
fmt.wprintf(writer, "[Attr] %v: %v\n", attr.key, attr.val)
|
||||
}
|
||||
} else if element.kind == .Comment {
|
||||
wprintf(writer, "[COMMENT] %v\n", element.value)
|
||||
fmt.wprintf(writer, "[COMMENT] %v\n", element.value)
|
||||
}
|
||||
|
||||
return written, .None
|
||||
@@ -291,8 +288,6 @@ doc_to_string :: proc(doc: ^xml.Document) -> (result: string) {
|
||||
|
||||
@test
|
||||
run_tests :: proc(t: ^testing.T) {
|
||||
using fmt
|
||||
|
||||
for test in TESTS {
|
||||
path := test_file_path(test.filename)
|
||||
log(t, fmt.tprintf("Trying to parse %v", path))
|
||||
@@ -307,11 +302,11 @@ run_tests :: proc(t: ^testing.T) {
|
||||
crc32 := hash.crc32(tree_bytes)
|
||||
|
||||
failed := err != test.err
|
||||
err_msg := tprintf("Expected return value %v, got %v", test.err, err)
|
||||
err_msg := fmt.tprintf("Expected return value %v, got %v", test.err, err)
|
||||
expect(t, err == test.err, err_msg)
|
||||
|
||||
failed |= crc32 != test.crc32
|
||||
err_msg = tprintf("Expected CRC 0x%08x, got 0x%08x, with options %v", test.crc32, crc32, test.options)
|
||||
err_msg = fmt.tprintf("Expected CRC 0x%08x, got 0x%08x, with options %v", test.crc32, crc32, test.options)
|
||||
expect(t, crc32 == test.crc32, err_msg)
|
||||
|
||||
if failed {
|
||||
@@ -319,7 +314,7 @@ run_tests :: proc(t: ^testing.T) {
|
||||
Don't fully print big trees.
|
||||
*/
|
||||
tree_string = tree_string[:min(2_048, len(tree_string))]
|
||||
println(tree_string)
|
||||
fmt.println(tree_string)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Tests "linalg_glsl_math.odin" in "core:math/linalg/glsl".
|
||||
// Must be run with `-collection:tests=` flag, e.g.
|
||||
// ./odin run tests/core/math/linalg/glsl/test_linalg_glsl_math.odin -collection:tests=./tests
|
||||
//+vet !using-stmt
|
||||
package test_core_math_linalg_glsl_math
|
||||
|
||||
import glsl "core:math/linalg/glsl"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Tests "math.odin" in "core:math".
|
||||
// Must be run with `-collection:tests=` flag, e.g.
|
||||
// ./odin run tests/core/math/test_core_math.odin -collection:tests=./tests
|
||||
//+vet !using-stmt
|
||||
package test_core_math
|
||||
|
||||
import "core:fmt"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//+vet !using-stmt
|
||||
package test_core_text_i18n
|
||||
|
||||
import "core:mem"
|
||||
|
||||
Reference in New Issue
Block a user