From 67cae423944fdcd460133502ff3ed9850135e8e6 Mon Sep 17 00:00:00 2001 From: Siddharth Bhatia <32610387+Sid-Bhatia-0@users.noreply.github.com> Date: Sat, 12 Feb 2022 21:57:32 +0530 Subject: [PATCH] fix type propogation and update tests (#44) * have a single integer type I * convert ray stop coordinates to Rational{I} * remove explicit convert to type I for i_ray_hit_tile and j_ray_hit_tile * fix some type propagations * check ray stop coordinates with === --- src/RayCaster.jl | 16 +- test/runtests.jl | 575 +++++++++++++++++++++++------------------------ 2 files changed, 295 insertions(+), 296 deletions(-) diff --git a/src/RayCaster.jl b/src/RayCaster.jl index c1cb29e..a7e75e0 100644 --- a/src/RayCaster.jl +++ b/src/RayCaster.jl @@ -1,7 +1,7 @@ module RayCaster -get_segment_start(i, segment_length) = (i - one(i)) * segment_length + one(segment_length) -get_segment_end(i, segment_length) = i * segment_length + one(segment_length) +get_segment_start(i, segment_length) = oftype(segment_length, (i - one(i)) * segment_length + one(segment_length)) +get_segment_end(i, segment_length) = oftype(segment_length, i * segment_length + one(segment_length)) get_segment(x, segment_length) = convert(Int, fld1(x, segment_length)) scaled_section_formula(x1, y1, x2, y2, m, n) = (m * x2 + n * x1, m * y2 + n * y1) @@ -70,15 +70,15 @@ function cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ra end if hit_dimension == 1 - height_ray_triangle_numerator = distance_traveled_along_x_axis_to_exit_ray_start_tile + (i_steps_taken - one(i_steps_taken)) * tile_length + height_ray_triangle_numerator = oftype(tile_length, distance_traveled_along_x_axis_to_exit_ray_start_tile + (i_steps_taken - one(i_steps_taken)) * tile_length) height_ray_triangle_denominator = one(height_ray_triangle_numerator) - width_ray_triangle_numerator = height_ray_triangle_numerator * abs_y_ray_direction - width_ray_triangle_denominator = abs_x_ray_direction + width_ray_triangle_numerator = oftype(tile_length, height_ray_triangle_numerator * abs_y_ray_direction) + width_ray_triangle_denominator = oftype(tile_length, abs_x_ray_direction) else - width_ray_triangle_numerator = distance_traveled_along_y_axis_to_exit_ray_start_tile + (j_steps_taken - one(j_steps_taken)) * tile_length + width_ray_triangle_numerator = oftype(tile_length, distance_traveled_along_y_axis_to_exit_ray_start_tile + (j_steps_taken - one(j_steps_taken)) * tile_length) width_ray_triangle_denominator = one(width_ray_triangle_numerator) - height_ray_triangle_numerator = width_ray_triangle_numerator * abs_x_ray_direction - height_ray_triangle_denominator = abs_y_ray_direction + height_ray_triangle_numerator = oftype(tile_length, width_ray_triangle_numerator * abs_x_ray_direction) + height_ray_triangle_denominator = oftype(tile_length, abs_y_ray_direction) end x_ray_stop_numerator = x_ray_start * height_ray_triangle_denominator + sign_x_ray_direction * height_ray_triangle_numerator diff --git a/test/runtests.jl b/test/runtests.jl index d4fbfeb..f33f0c4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -11,10 +11,9 @@ Test.@testset "RayCaster.jl" begin ]) max_steps = 1024 - I = Int - Test.@testset "TileLengthType = $(TileLengthType), RayPositionType = $(RayPositionType), RayDirectionType = $(RayDirectionType), max_steps = $(max_steps)" for (RayPositionType, RayDirectionType) in [(Int, Int)], TileLengthType in [Int, Int32] + Test.@testset "I = $(I), max_steps = $(max_steps)" for I in [Int, Int32] - tile_length = convert(TileLengthType, 8) + tile_length = convert(I, 8) Test.@testset "tile_length = $(tile_length)" begin i_ray_start_tile = convert(I, 2) @@ -23,131 +22,131 @@ Test.@testset "RayCaster.jl" begin x_ray_start_relative_to_tile = convert(I, 1) y_ray_start_relative_to_tile = convert(I, 1) - x_ray_start = convert(RayPositionType, RC.get_segment_start(i_ray_start_tile, tile_length) + x_ray_start_relative_to_tile - one(x_ray_start_relative_to_tile)) - y_ray_start = convert(RayPositionType, RC.get_segment_start(j_ray_start_tile, tile_length) + y_ray_start_relative_to_tile - one(y_ray_start_relative_to_tile)) + x_ray_start = convert(I, RC.get_segment_start(i_ray_start_tile, tile_length) + x_ray_start_relative_to_tile - one(x_ray_start_relative_to_tile)) + y_ray_start = convert(I, RC.get_segment_start(j_ray_start_tile, tile_length) + y_ray_start_relative_to_tile - one(y_ray_start_relative_to_tile)) Test.@testset "x_ray_start = $(x_ray_start), y_ray_start = $(y_ray_start)" begin - x_ray_direction = convert(RayDirectionType, 1) - y_ray_direction = convert(RayDirectionType, 0) + x_ray_direction = convert(I, 1) + y_ray_direction = convert(I, 0) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 33//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 9//1 - Test.@test i_ray_hit_tile == convert(I, 5) - Test.@test j_ray_hit_tile == convert(I, 2) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 9//1) + Test.@test i_ray_hit_tile == 5 + Test.@test j_ray_hit_tile == 2 Test.@test hit_dimension == 1 end - x_ray_direction = convert(RayDirectionType, 1) - y_ray_direction = convert(RayDirectionType, 1) + x_ray_direction = convert(I, 1) + y_ray_direction = convert(I, 1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 17//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 17//1 - Test.@test i_ray_hit_tile == convert(I, 3) - Test.@test j_ray_hit_tile == convert(I, 3) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 17//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 17//1) + Test.@test i_ray_hit_tile == 3 + Test.@test j_ray_hit_tile == 3 Test.@test hit_dimension == 2 end - x_ray_direction = convert(RayDirectionType, 0) - y_ray_direction = convert(RayDirectionType, 1) + x_ray_direction = convert(I, 0) + y_ray_direction = convert(I, 1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 9//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 33//1 - Test.@test i_ray_hit_tile == convert(I, 2) - Test.@test j_ray_hit_tile == convert(I, 5) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 9//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test i_ray_hit_tile == 2 + Test.@test j_ray_hit_tile == 5 Test.@test hit_dimension == 2 end - x_ray_direction = convert(RayDirectionType, -1) - y_ray_direction = convert(RayDirectionType, 1) + x_ray_direction = convert(I, -1) + y_ray_direction = convert(I, 1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 9//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 9//1 - Test.@test i_ray_hit_tile == convert(I, 1) - Test.@test j_ray_hit_tile == convert(I, 2) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 9//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 9//1) + Test.@test i_ray_hit_tile == 1 + Test.@test j_ray_hit_tile == 2 Test.@test hit_dimension == 1 end - x_ray_direction = convert(RayDirectionType, -1) - y_ray_direction = convert(RayDirectionType, 0) + x_ray_direction = convert(I, -1) + y_ray_direction = convert(I, 0) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 9//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 9//1 - Test.@test i_ray_hit_tile == convert(I, 1) - Test.@test j_ray_hit_tile == convert(I, 2) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 9//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 9//1) + Test.@test i_ray_hit_tile == 1 + Test.@test j_ray_hit_tile == 2 Test.@test hit_dimension == 1 end - x_ray_direction = convert(RayDirectionType, -1) - y_ray_direction = convert(RayDirectionType, -1) + x_ray_direction = convert(I, -1) + y_ray_direction = convert(I, -1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 9//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 9//1 - Test.@test i_ray_hit_tile == convert(I, 1) - Test.@test j_ray_hit_tile == convert(I, 2) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 9//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 9//1) + Test.@test i_ray_hit_tile == 1 + Test.@test j_ray_hit_tile == 2 Test.@test hit_dimension == 1 end - x_ray_direction = convert(RayDirectionType, 0) - y_ray_direction = convert(RayDirectionType, -1) + x_ray_direction = convert(I, 0) + y_ray_direction = convert(I, -1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 9//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 9//1 - Test.@test i_ray_hit_tile == convert(I, 2) - Test.@test j_ray_hit_tile == convert(I, 1) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 9//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 9//1) + Test.@test i_ray_hit_tile == 2 + Test.@test j_ray_hit_tile == 1 Test.@test hit_dimension == 2 end - x_ray_direction = convert(RayDirectionType, 1) - y_ray_direction = convert(RayDirectionType, -1) + x_ray_direction = convert(I, 1) + y_ray_direction = convert(I, -1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 9//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 9//1 - Test.@test i_ray_hit_tile == convert(I, 2) - Test.@test j_ray_hit_tile == convert(I, 1) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 9//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 9//1) + Test.@test i_ray_hit_tile == 2 + Test.@test j_ray_hit_tile == 1 Test.@test hit_dimension == 2 end end x_ray_start_relative_to_tile = convert(I, 9) y_ray_start_relative_to_tile = convert(I, 5) - x_ray_start = convert(RayPositionType, RC.get_segment_start(i_ray_start_tile, tile_length) + x_ray_start_relative_to_tile - one(x_ray_start_relative_to_tile)) - y_ray_start = convert(RayPositionType, RC.get_segment_start(j_ray_start_tile, tile_length) + y_ray_start_relative_to_tile - one(y_ray_start_relative_to_tile)) + x_ray_start = convert(I, RC.get_segment_start(i_ray_start_tile, tile_length) + x_ray_start_relative_to_tile - one(x_ray_start_relative_to_tile)) + y_ray_start = convert(I, RC.get_segment_start(j_ray_start_tile, tile_length) + y_ray_start_relative_to_tile - one(y_ray_start_relative_to_tile)) Test.@testset "x_ray_start = $(x_ray_start), y_ray_start = $(y_ray_start)" begin - x_ray_direction = convert(RayDirectionType, 0) - y_ray_direction = convert(RayDirectionType, 1) + x_ray_direction = convert(I, 0) + y_ray_direction = convert(I, 1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 17//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 17//1 - Test.@test i_ray_hit_tile == convert(I, 3) - Test.@test j_ray_hit_tile == convert(I, 3) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 17//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 17//1) + Test.@test i_ray_hit_tile == 3 + Test.@test j_ray_hit_tile == 3 Test.@test hit_dimension == 2 end end x_ray_start_relative_to_tile = convert(I, 5) y_ray_start_relative_to_tile = convert(I, 9) - x_ray_start = convert(RayPositionType, RC.get_segment_start(i_ray_start_tile, tile_length) + x_ray_start_relative_to_tile - one(x_ray_start_relative_to_tile)) - y_ray_start = convert(RayPositionType, RC.get_segment_start(j_ray_start_tile, tile_length) + y_ray_start_relative_to_tile - one(y_ray_start_relative_to_tile)) + x_ray_start = convert(I, RC.get_segment_start(i_ray_start_tile, tile_length) + x_ray_start_relative_to_tile - one(x_ray_start_relative_to_tile)) + y_ray_start = convert(I, RC.get_segment_start(j_ray_start_tile, tile_length) + y_ray_start_relative_to_tile - one(y_ray_start_relative_to_tile)) Test.@testset "x_ray_start = $(x_ray_start), y_ray_start = $(y_ray_start)" begin - x_ray_direction = convert(RayDirectionType, 1) - y_ray_direction = convert(RayDirectionType, 0) + x_ray_direction = convert(I, 1) + y_ray_direction = convert(I, 0) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 17//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 17//1 - Test.@test i_ray_hit_tile == convert(I, 3) - Test.@test j_ray_hit_tile == convert(I, 3) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 17//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 17//1) + Test.@test i_ray_hit_tile == 3 + Test.@test j_ray_hit_tile == 3 Test.@test hit_dimension == 1 end end @@ -159,190 +158,190 @@ Test.@testset "RayCaster.jl" begin x_ray_start_relative_to_tile = convert(I, 1) y_ray_start_relative_to_tile = convert(I, 1) - x_ray_start = convert(RayPositionType, RC.get_segment_start(i_ray_start_tile, tile_length) + x_ray_start_relative_to_tile - one(x_ray_start_relative_to_tile)) - y_ray_start = convert(RayPositionType, RC.get_segment_start(j_ray_start_tile, tile_length) + y_ray_start_relative_to_tile - one(y_ray_start_relative_to_tile)) + x_ray_start = convert(I, RC.get_segment_start(i_ray_start_tile, tile_length) + x_ray_start_relative_to_tile - one(x_ray_start_relative_to_tile)) + y_ray_start = convert(I, RC.get_segment_start(j_ray_start_tile, tile_length) + y_ray_start_relative_to_tile - one(y_ray_start_relative_to_tile)) Test.@testset "x_ray_start = $(x_ray_start), y_ray_start = $(y_ray_start)" begin - x_ray_direction = convert(RayDirectionType, 1) - y_ray_direction = convert(RayDirectionType, 0) + x_ray_direction = convert(I, 1) + y_ray_direction = convert(I, 0) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 33//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 25//1 - Test.@test i_ray_hit_tile == convert(I, 5) - Test.@test j_ray_hit_tile == convert(I, 4) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 25//1) + Test.@test i_ray_hit_tile == 5 + Test.@test j_ray_hit_tile == 4 Test.@test hit_dimension == 1 end - x_ray_direction = convert(RayDirectionType, 3) - y_ray_direction = convert(RayDirectionType, 1) + x_ray_direction = convert(I, 3) + y_ray_direction = convert(I, 1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 33//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 83//3 - Test.@test i_ray_hit_tile == convert(I, 5) - Test.@test j_ray_hit_tile == convert(I, 4) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 83//3) + Test.@test i_ray_hit_tile == 5 + Test.@test j_ray_hit_tile == 4 Test.@test hit_dimension == 1 end - x_ray_direction = convert(RayDirectionType, 1) - y_ray_direction = convert(RayDirectionType, 1) + x_ray_direction = convert(I, 1) + y_ray_direction = convert(I, 1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 33//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 33//1 - Test.@test i_ray_hit_tile == convert(I, 5) - Test.@test j_ray_hit_tile == convert(I, 4) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test i_ray_hit_tile == 5 + Test.@test j_ray_hit_tile == 4 Test.@test hit_dimension == 1 end - x_ray_direction = convert(RayDirectionType, 1) - y_ray_direction = convert(RayDirectionType, 3) + x_ray_direction = convert(I, 1) + y_ray_direction = convert(I, 3) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 83//3 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 33//1 - Test.@test i_ray_hit_tile == convert(I, 4) - Test.@test j_ray_hit_tile == convert(I, 5) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 83//3) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test i_ray_hit_tile == 4 + Test.@test j_ray_hit_tile == 5 Test.@test hit_dimension == 2 end - x_ray_direction = convert(RayDirectionType, 0) - y_ray_direction = convert(RayDirectionType, 1) + x_ray_direction = convert(I, 0) + y_ray_direction = convert(I, 1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 25//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 33//1 - Test.@test i_ray_hit_tile == convert(I, 4) - Test.@test j_ray_hit_tile == convert(I, 5) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 25//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test i_ray_hit_tile == 4 + Test.@test j_ray_hit_tile == 5 Test.@test hit_dimension == 2 end - x_ray_direction = convert(RayDirectionType, -1) - y_ray_direction = convert(RayDirectionType, 3) + x_ray_direction = convert(I, -1) + y_ray_direction = convert(I, 3) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 67//3 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 33//1 - Test.@test i_ray_hit_tile == convert(I, 3) - Test.@test j_ray_hit_tile == convert(I, 5) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 67//3) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test i_ray_hit_tile == 3 + Test.@test j_ray_hit_tile == 5 Test.@test hit_dimension == 2 end - x_ray_direction = convert(RayDirectionType, -1) - y_ray_direction = convert(RayDirectionType, 1) + x_ray_direction = convert(I, -1) + y_ray_direction = convert(I, 1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 17//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 33//1 - Test.@test i_ray_hit_tile == convert(I, 2) - Test.@test j_ray_hit_tile == convert(I, 5) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 17//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test i_ray_hit_tile == 2 + Test.@test j_ray_hit_tile == 5 Test.@test hit_dimension == 2 end - x_ray_direction = convert(RayDirectionType, -3) - y_ray_direction = convert(RayDirectionType, 1) + x_ray_direction = convert(I, -3) + y_ray_direction = convert(I, 1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 9//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 91//3 - Test.@test i_ray_hit_tile == convert(I, 1) - Test.@test j_ray_hit_tile == convert(I, 4) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 9//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 91//3) + Test.@test i_ray_hit_tile == 1 + Test.@test j_ray_hit_tile == 4 Test.@test hit_dimension == 1 end - x_ray_direction = convert(RayDirectionType, -1) - y_ray_direction = convert(RayDirectionType, 0) + x_ray_direction = convert(I, -1) + y_ray_direction = convert(I, 0) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 9//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 25//1 - Test.@test i_ray_hit_tile == convert(I, 1) - Test.@test j_ray_hit_tile == convert(I, 4) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 9//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 25//1) + Test.@test i_ray_hit_tile == 1 + Test.@test j_ray_hit_tile == 4 Test.@test hit_dimension == 1 end - x_ray_direction = convert(RayDirectionType, -3) - y_ray_direction = convert(RayDirectionType, -1) + x_ray_direction = convert(I, -3) + y_ray_direction = convert(I, -1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 25//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 25//1 - Test.@test i_ray_hit_tile == convert(I, 3) - Test.@test j_ray_hit_tile == convert(I, 3) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 25//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 25//1) + Test.@test i_ray_hit_tile == 3 + Test.@test j_ray_hit_tile == 3 Test.@test hit_dimension == 2 end - x_ray_direction = convert(RayDirectionType, -1) - y_ray_direction = convert(RayDirectionType, -1) + x_ray_direction = convert(I, -1) + y_ray_direction = convert(I, -1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 25//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 25//1 - Test.@test i_ray_hit_tile == convert(I, 3) - Test.@test j_ray_hit_tile == convert(I, 3) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 25//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 25//1) + Test.@test i_ray_hit_tile == 3 + Test.@test j_ray_hit_tile == 3 Test.@test hit_dimension == 2 end - x_ray_direction = convert(RayDirectionType, -1) - y_ray_direction = convert(RayDirectionType, -3) + x_ray_direction = convert(I, -1) + y_ray_direction = convert(I, -3) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 25//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 25//1 - Test.@test i_ray_hit_tile == convert(I, 3) - Test.@test j_ray_hit_tile == convert(I, 3) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 25//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 25//1) + Test.@test i_ray_hit_tile == 3 + Test.@test j_ray_hit_tile == 3 Test.@test hit_dimension == 2 end - x_ray_direction = convert(RayDirectionType, 0) - y_ray_direction = convert(RayDirectionType, -1) + x_ray_direction = convert(I, 0) + y_ray_direction = convert(I, -1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 25//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 9//1 - Test.@test i_ray_hit_tile == convert(I, 4) - Test.@test j_ray_hit_tile == convert(I, 1) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 25//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 9//1) + Test.@test i_ray_hit_tile == 4 + Test.@test j_ray_hit_tile == 1 Test.@test hit_dimension == 2 end - x_ray_direction = convert(RayDirectionType, 1) - y_ray_direction = convert(RayDirectionType, -3) + x_ray_direction = convert(I, 1) + y_ray_direction = convert(I, -3) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 91//3 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 9//1 - Test.@test i_ray_hit_tile == convert(I, 4) - Test.@test j_ray_hit_tile == convert(I, 1) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 91//3) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 9//1) + Test.@test i_ray_hit_tile == 4 + Test.@test j_ray_hit_tile == 1 Test.@test hit_dimension == 2 end - x_ray_direction = convert(RayDirectionType, 1) - y_ray_direction = convert(RayDirectionType, -1) + x_ray_direction = convert(I, 1) + y_ray_direction = convert(I, -1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 33//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 17//1 - Test.@test i_ray_hit_tile == convert(I, 5) - Test.@test j_ray_hit_tile == convert(I, 3) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 17//1) + Test.@test i_ray_hit_tile == 5 + Test.@test j_ray_hit_tile == 3 Test.@test hit_dimension == 1 end - x_ray_direction = convert(RayDirectionType, 3) - y_ray_direction = convert(RayDirectionType, -1) + x_ray_direction = convert(I, 3) + y_ray_direction = convert(I, -1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 33//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 67//3 - Test.@test i_ray_hit_tile == convert(I, 5) - Test.@test j_ray_hit_tile == convert(I, 3) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 67//3) + Test.@test i_ray_hit_tile == 5 + Test.@test j_ray_hit_tile == 3 Test.@test hit_dimension == 1 end end end end - tile_length = convert(TileLengthType, 1) + tile_length = convert(I, 1) Test.@testset "tile_length = $(tile_length)" begin i_ray_start_tile = convert(I, 4) @@ -351,102 +350,102 @@ Test.@testset "RayCaster.jl" begin x_ray_start_relative_to_tile = convert(I, 1) y_ray_start_relative_to_tile = convert(I, 1) - x_ray_start = convert(RayPositionType, RC.get_segment_start(i_ray_start_tile, tile_length) + x_ray_start_relative_to_tile - one(x_ray_start_relative_to_tile)) - y_ray_start = convert(RayPositionType, RC.get_segment_start(j_ray_start_tile, tile_length) + y_ray_start_relative_to_tile - one(y_ray_start_relative_to_tile)) + x_ray_start = convert(I, RC.get_segment_start(i_ray_start_tile, tile_length) + x_ray_start_relative_to_tile - one(x_ray_start_relative_to_tile)) + y_ray_start = convert(I, RC.get_segment_start(j_ray_start_tile, tile_length) + y_ray_start_relative_to_tile - one(y_ray_start_relative_to_tile)) Test.@testset "x_ray_start = $(x_ray_start), y_ray_start = $(y_ray_start)" begin - x_ray_direction = convert(RayDirectionType, 1) - y_ray_direction = convert(RayDirectionType, 0) + x_ray_direction = convert(I, 1) + y_ray_direction = convert(I, 0) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 5//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 4//1 - Test.@test i_ray_hit_tile == convert(I, 5) - Test.@test j_ray_hit_tile == convert(I, 4) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 5//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 4//1) + Test.@test i_ray_hit_tile == 5 + Test.@test j_ray_hit_tile == 4 Test.@test hit_dimension == 1 end - x_ray_direction = convert(RayDirectionType, 1) - y_ray_direction = convert(RayDirectionType, 1) + x_ray_direction = convert(I, 1) + y_ray_direction = convert(I, 1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 5//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 5//1 - Test.@test i_ray_hit_tile == convert(I, 5) - Test.@test j_ray_hit_tile == convert(I, 4) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 5//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 5//1) + Test.@test i_ray_hit_tile == 5 + Test.@test j_ray_hit_tile == 4 Test.@test hit_dimension == 1 end - x_ray_direction = convert(RayDirectionType, 0) - y_ray_direction = convert(RayDirectionType, 1) + x_ray_direction = convert(I, 0) + y_ray_direction = convert(I, 1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 4//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 5//1 - Test.@test i_ray_hit_tile == convert(I, 4) - Test.@test j_ray_hit_tile == convert(I, 5) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 4//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 5//1) + Test.@test i_ray_hit_tile == 4 + Test.@test j_ray_hit_tile == 5 Test.@test hit_dimension == 2 end - x_ray_direction = convert(RayDirectionType, -1) - y_ray_direction = convert(RayDirectionType, 1) + x_ray_direction = convert(I, -1) + y_ray_direction = convert(I, 1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 3//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 5//1 - Test.@test i_ray_hit_tile == convert(I, 2) - Test.@test j_ray_hit_tile == convert(I, 5) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 3//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 5//1) + Test.@test i_ray_hit_tile == 2 + Test.@test j_ray_hit_tile == 5 Test.@test hit_dimension == 2 end - x_ray_direction = convert(RayDirectionType, -1) - y_ray_direction = convert(RayDirectionType, 0) + x_ray_direction = convert(I, -1) + y_ray_direction = convert(I, 0) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 2//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 4//1 - Test.@test i_ray_hit_tile == convert(I, 1) - Test.@test j_ray_hit_tile == convert(I, 4) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 2//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 4//1) + Test.@test i_ray_hit_tile == 1 + Test.@test j_ray_hit_tile == 4 Test.@test hit_dimension == 1 end - x_ray_direction = convert(RayDirectionType, -1) - y_ray_direction = convert(RayDirectionType, -1) + x_ray_direction = convert(I, -1) + y_ray_direction = convert(I, -1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 4//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 4//1 - Test.@test i_ray_hit_tile == convert(I, 3) - Test.@test j_ray_hit_tile == convert(I, 3) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 4//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 4//1) + Test.@test i_ray_hit_tile == 3 + Test.@test j_ray_hit_tile == 3 Test.@test hit_dimension == 2 end - x_ray_direction = convert(RayDirectionType, 0) - y_ray_direction = convert(RayDirectionType, -1) + x_ray_direction = convert(I, 0) + y_ray_direction = convert(I, -1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 4//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 2//1 - Test.@test i_ray_hit_tile == convert(I, 4) - Test.@test j_ray_hit_tile == convert(I, 1) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 4//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 2//1) + Test.@test i_ray_hit_tile == 4 + Test.@test j_ray_hit_tile == 1 Test.@test hit_dimension == 2 end - x_ray_direction = convert(RayDirectionType, 1) - y_ray_direction = convert(RayDirectionType, -1) + x_ray_direction = convert(I, 1) + y_ray_direction = convert(I, -1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 5//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 3//1 - Test.@test i_ray_hit_tile == convert(I, 5) - Test.@test j_ray_hit_tile == convert(I, 3) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 5//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 3//1) + Test.@test i_ray_hit_tile == 5 + Test.@test j_ray_hit_tile == 3 Test.@test hit_dimension == 1 end end end end - tile_length = convert(TileLengthType, 256) + tile_length = convert(I, 256) Test.@testset "tile_length = $(tile_length)" begin i_ray_start_tile = convert(I, 2) @@ -455,16 +454,16 @@ Test.@testset "RayCaster.jl" begin x_ray_start_relative_to_tile = convert(I, tile_length ÷ 2 + 1) y_ray_start_relative_to_tile = convert(I, tile_length ÷ 2 + 1) - x_ray_start = convert(RayPositionType, RC.get_segment_start(i_ray_start_tile, tile_length) + x_ray_start_relative_to_tile - one(x_ray_start_relative_to_tile)) - y_ray_start = convert(RayPositionType, RC.get_segment_start(j_ray_start_tile, tile_length) + y_ray_start_relative_to_tile - one(y_ray_start_relative_to_tile)) + x_ray_start = convert(I, RC.get_segment_start(i_ray_start_tile, tile_length) + x_ray_start_relative_to_tile - one(x_ray_start_relative_to_tile)) + y_ray_start = convert(I, RC.get_segment_start(j_ray_start_tile, tile_length) + y_ray_start_relative_to_tile - one(y_ray_start_relative_to_tile)) Test.@testset "x_ray_start = $(x_ray_start), y_ray_start = $(y_ray_start)" begin - x_direction = convert(RayDirectionType, 1) - y_direction = convert(RayDirectionType, 1) + x_direction = convert(I, 1) + y_direction = convert(I, 1) semi_field_of_view_ratio = 2//3 num_rays = 9 Test.@testset "x_direction = $(x_direction), y_direction = $(y_direction)" begin - outputs = Vector{Tuple{I, I, I, I, I, I, Int, RayDirectionType, RayDirectionType}}(undef, num_rays) + outputs = Vector{Tuple{I, I, I, I, I, I, Int, I, I}}(undef, num_rays) RC.cast_rays!(outputs, obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_direction, y_direction, semi_field_of_view_ratio, max_steps, i_ray_start_tile, j_ray_start_tile) end end @@ -503,10 +502,10 @@ Test.@testset "RayCaster.jl" begin y_ray_direction = convert(I, 0) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 41//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 33//1 - Test.@test i_ray_hit_tile == convert(I, 6) - Test.@test j_ray_hit_tile == convert(I, 5) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 41//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test i_ray_hit_tile == 6 + Test.@test j_ray_hit_tile == 5 Test.@test hit_dimension == 1 end @@ -514,10 +513,10 @@ Test.@testset "RayCaster.jl" begin y_ray_direction = convert(I, 1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 41//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 41//1 - Test.@test i_ray_hit_tile == convert(I, 6) - Test.@test j_ray_hit_tile == convert(I, 5) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 41//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 41//1) + Test.@test i_ray_hit_tile == 6 + Test.@test j_ray_hit_tile == 5 Test.@test hit_dimension == 1 end @@ -525,10 +524,10 @@ Test.@testset "RayCaster.jl" begin y_ray_direction = convert(I, 1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 33//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 41//1 - Test.@test i_ray_hit_tile == convert(I, 5) - Test.@test j_ray_hit_tile == convert(I, 6) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 41//1) + Test.@test i_ray_hit_tile == 5 + Test.@test j_ray_hit_tile == 6 Test.@test hit_dimension == 2 end @@ -536,10 +535,10 @@ Test.@testset "RayCaster.jl" begin y_ray_direction = convert(I, 1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 33//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 33//1 - Test.@test i_ray_hit_tile == convert(I, 4) - Test.@test j_ray_hit_tile == convert(I, 5) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test i_ray_hit_tile == 4 + Test.@test j_ray_hit_tile == 5 Test.@test hit_dimension == 1 end @@ -547,10 +546,10 @@ Test.@testset "RayCaster.jl" begin y_ray_direction = convert(I, 0) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 33//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 33//1 - Test.@test i_ray_hit_tile == convert(I, 4) - Test.@test j_ray_hit_tile == convert(I, 5) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test i_ray_hit_tile == 4 + Test.@test j_ray_hit_tile == 5 Test.@test hit_dimension == 1 end @@ -558,10 +557,10 @@ Test.@testset "RayCaster.jl" begin y_ray_direction = convert(I, -1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 33//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 33//1 - Test.@test i_ray_hit_tile == convert(I, 4) - Test.@test j_ray_hit_tile == convert(I, 5) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test i_ray_hit_tile == 4 + Test.@test j_ray_hit_tile == 5 Test.@test hit_dimension == 1 end @@ -569,10 +568,10 @@ Test.@testset "RayCaster.jl" begin y_ray_direction = convert(I, -1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 33//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 33//1 - Test.@test i_ray_hit_tile == convert(I, 5) - Test.@test j_ray_hit_tile == convert(I, 4) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test i_ray_hit_tile == 5 + Test.@test j_ray_hit_tile == 4 Test.@test hit_dimension == 2 end @@ -580,10 +579,10 @@ Test.@testset "RayCaster.jl" begin y_ray_direction = convert(I, -1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 33//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 33//1 - Test.@test i_ray_hit_tile == convert(I, 5) - Test.@test j_ray_hit_tile == convert(I, 4) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test i_ray_hit_tile == 5 + Test.@test j_ray_hit_tile == 4 Test.@test hit_dimension == 2 end end @@ -594,10 +593,10 @@ Test.@testset "RayCaster.jl" begin y_ray_direction = convert(I, 0) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 49//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 33//1 - Test.@test i_ray_hit_tile == convert(I, 7) - Test.@test j_ray_hit_tile == convert(I, 5) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 49//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test i_ray_hit_tile == 7 + Test.@test j_ray_hit_tile == 5 Test.@test hit_dimension == 1 end @@ -605,10 +604,10 @@ Test.@testset "RayCaster.jl" begin y_ray_direction = convert(I, 1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 49//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 49//1 - Test.@test i_ray_hit_tile == convert(I, 7) - Test.@test j_ray_hit_tile == convert(I, 6) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 49//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 49//1) + Test.@test i_ray_hit_tile == 7 + Test.@test j_ray_hit_tile == 6 Test.@test hit_dimension == 1 end @@ -616,10 +615,10 @@ Test.@testset "RayCaster.jl" begin y_ray_direction = convert(I, 1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 33//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 49//1 - Test.@test i_ray_hit_tile == convert(I, 5) - Test.@test j_ray_hit_tile == convert(I, 7) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 49//1) + Test.@test i_ray_hit_tile == 5 + Test.@test j_ray_hit_tile == 7 Test.@test hit_dimension == 2 end @@ -627,10 +626,10 @@ Test.@testset "RayCaster.jl" begin y_ray_direction = convert(I, 1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 25//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 41//1 - Test.@test i_ray_hit_tile == convert(I, 3) - Test.@test j_ray_hit_tile == convert(I, 5) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 25//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 41//1) + Test.@test i_ray_hit_tile == 3 + Test.@test j_ray_hit_tile == 5 Test.@test hit_dimension == 1 end @@ -638,10 +637,10 @@ Test.@testset "RayCaster.jl" begin y_ray_direction = convert(I, 0) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 25//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 33//1 - Test.@test i_ray_hit_tile == convert(I, 3) - Test.@test j_ray_hit_tile == convert(I, 5) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 25//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test i_ray_hit_tile == 3 + Test.@test j_ray_hit_tile == 5 Test.@test hit_dimension == 1 end @@ -649,10 +648,10 @@ Test.@testset "RayCaster.jl" begin y_ray_direction = convert(I, -1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 25//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 25//1 - Test.@test i_ray_hit_tile == convert(I, 3) - Test.@test j_ray_hit_tile == convert(I, 4) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 25//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 25//1) + Test.@test i_ray_hit_tile == 3 + Test.@test j_ray_hit_tile == 4 Test.@test hit_dimension == 1 end @@ -660,10 +659,10 @@ Test.@testset "RayCaster.jl" begin y_ray_direction = convert(I, -1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 33//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 25//1 - Test.@test i_ray_hit_tile == convert(I, 5) - Test.@test j_ray_hit_tile == convert(I, 3) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 33//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 25//1) + Test.@test i_ray_hit_tile == 5 + Test.@test j_ray_hit_tile == 3 Test.@test hit_dimension == 2 end @@ -671,10 +670,10 @@ Test.@testset "RayCaster.jl" begin y_ray_direction = convert(I, -1) Test.@testset "x_ray_direction = $(x_ray_direction), y_ray_direction = $(y_ray_direction)" begin x_ray_stop_numerator, x_ray_stop_denominator, y_ray_stop_numerator, y_ray_stop_denominator, i_ray_hit_tile, j_ray_hit_tile, hit_dimension = RC.cast_ray(obstacle_tile_map, tile_length, x_ray_start, y_ray_start, x_ray_direction, y_ray_direction, max_steps) - Test.@test x_ray_stop_numerator//x_ray_stop_denominator == 41//1 - Test.@test y_ray_stop_numerator//y_ray_stop_denominator == 25//1 - Test.@test i_ray_hit_tile == convert(I, 6) - Test.@test j_ray_hit_tile == convert(I, 3) + Test.@test x_ray_stop_numerator//x_ray_stop_denominator === convert(Rational{I}, 41//1) + Test.@test y_ray_stop_numerator//y_ray_stop_denominator === convert(Rational{I}, 25//1) + Test.@test i_ray_hit_tile == 6 + Test.@test j_ray_hit_tile == 3 Test.@test hit_dimension == 2 end end