|
| 1 | + |
| 2 | +using error catching |
| 3 | + |
| 4 | +test "midpoint locations - simple": |
| 5 | + set {_loc1} to location(0, 0, 0) |
| 6 | + set {_loc2} to {_loc1} ~ vector(10, 10, 10) |
| 7 | + set {_midpoint} to the midpoint between {_loc1} and {_loc2} |
| 8 | + assert {_midpoint} is location(5, 5, 5) with "Simple midpoint loc1 -> loc2 is incorrect" |
| 9 | + set {_midpoint2} to the midpoint between {_loc2} and {_loc1} |
| 10 | + assert {_midpoint2} is location(5, 5, 5) with "Simple midpoint loc2 -> loc1 is incorrect" |
| 11 | + |
| 12 | +test "midpoint locations - complex": |
| 13 | + set {_loc1} to location(10.3, 38.6, 72.9) |
| 14 | + set {_loc2} to location(-24.2, 63.8, 598.1) |
| 15 | + set {_midpoint} to the midpoint between {_loc1} and {_loc2} |
| 16 | + assert {_midpoint} is location(-6.95, 51.2, 335.5) with "Complex midpoint loc1 -> loc2 is incorrect" |
| 17 | + set {_midpoint2} to the midpoint between {_loc2} and {_loc1} |
| 18 | + assert {_midpoint2} is location(-6.95, 51.2, 335.5) with "Complex midpoint loc2 -> loc1 is incorrect" |
| 19 | + |
| 20 | +test "midpoint locations - negative": |
| 21 | + set {_loc1} to location(-48.2, -33.6, -97.8) |
| 22 | + set {_loc2} to location(-257.3, -59.3, -327.4) |
| 23 | + set {_midpoint} to the midpoint between {_loc1} and {_loc2} |
| 24 | + assert {_midpoint} is location(-152.75, -46.45, -212.6) with "Negative midpoint loc1 -> loc2 is incorrect" |
| 25 | + set {_midpoint2} to the midpoint between {_loc2} and {_loc1} |
| 26 | + assert {_midpoint2} is location(-152.75, -46.45, -212.6) with "Negative midpoint loc2 -> loc1 is incorrect" |
| 27 | + |
| 28 | +test "midpoint locations - function/variable": |
| 29 | + set {_loc} to location(20, 30, 40) |
| 30 | + set {_midpoint} to the midpoint between location(50, 60, 70) and {_loc} |
| 31 | + assert {_midpoint} is location(35, 45, 55) with "Midpoint locations function -> variable is incorrect" |
| 32 | + set {_midpoint2} to the midpoint between {_loc} and location(50, 60, 70) |
| 33 | + assert {_midpoint2} is location(35, 45, 55) with "Midpoint locations variable -> function is incorrect" |
| 34 | + |
| 35 | +test "midpoint location - world error": |
| 36 | + set {_loc1} to location(0, 0, 0) |
| 37 | + set {_loc2} to location(0, 0, 0, "world_the_end") |
| 38 | + catch runtime errors: |
| 39 | + set {_midpoint} to the midpoint between {_loc1} and {_loc2} |
| 40 | + assert last caught errors is "Cannot get the midpoint of two locations in different worlds." with "ExprMidpoint should error when getting midpoint of locations in different worlds" |
| 41 | + |
| 42 | +test "midpoint vectors - simple": |
| 43 | + set {_vector1} to vector(0, 0, 0) |
| 44 | + set {_vector2} to vector(10, 10, 10) |
| 45 | + set {_midpoint} to the midpoint between {_vector1} and {_vector2} |
| 46 | + assert {_midpoint} is vector(5, 5, 5) with "Simple midpoint vector1 -> vector2 is incorrect" |
| 47 | + set {_midpoint2} to the midpoint between {_vector2} and {_vector1} |
| 48 | + assert {_midpoint2} is vector(5, 5, 5) with "Simple midpoint vector2 -> vector1 is incorrect" |
| 49 | + |
| 50 | +test "midpoint vectors - complex": |
| 51 | + set {_vector1} to vector(10.3, 38.6, 72.9) |
| 52 | + set {_vector2} to vector(-24.2, 63.8, 598.1) |
| 53 | + set {_midpoint} to the midpoint between {_vector1} and {_vector2} |
| 54 | + assert {_midpoint} is vector(-6.95, 51.2, 335.5) with "Complex midpoint vector1 -> vector2 is incorrect" |
| 55 | + set {_midpoint2} to the midpoint between {_vector2} and {_vector1} |
| 56 | + assert {_midpoint2} is vector(-6.95, 51.2, 335.5) with "Complex midpoint vector2 -> vector1 is incorrect" |
| 57 | + |
| 58 | +test "midpoint vectors - negative": |
| 59 | + set {_vector1} to vector(-48.2, -33.6, -97.8) |
| 60 | + set {_vector2} to vector(-257.3, -59.3, -327.4) |
| 61 | + set {_midpoint} to the midpoint between {_vector1} and {_vector2} |
| 62 | + assert {_midpoint} is vector(-152.75, -46.45, -212.6) with "Negative midpoint vector1 -> vector2 is incorrect" |
| 63 | + set {_midpoint2} to the midpoint between {_vector2} and {_vector1} |
| 64 | + assert {_midpoint2} is vector(-152.75, -46.45, -212.6) with "Negative midpoint vector2 -> vector1 is incorrect" |
| 65 | + |
| 66 | +test "midpoint vectors - function/variable": |
| 67 | + set {_vec} to vector(20, 30, 40) |
| 68 | + set {_midpoint} to the midpoint between vector(50, 60, 70) and {_vec} |
| 69 | + assert {_midpoint} is vector(35, 45, 55) with "Midpoint vectors function -> variable is incorrect" |
| 70 | + set {_midpoint2} to the midpoint between {_vec} and vector(50, 60, 70) |
| 71 | + assert {_midpoint2} is vector(35, 45, 55) with "Midpoint vectors variable -> function is incorrect" |
| 72 | + |
| 73 | +test "midpoint type error": |
| 74 | + parse: |
| 75 | + set {_midpoint} to the midpoint between location(0, 0, 0) and vector(0, 0, 0) |
| 76 | + assert last parse logs is set with "Midpoint between location and vector should error" |
| 77 | + assert last parse logs is "You can only get the midpoint between two locations or two vectors." with "Incorrect error of midpoint between location and vector" |
| 78 | + |
| 79 | + set {_loc} to location(0, 0, 0) |
| 80 | + set {_vector} to vector(0, 0, 0) |
| 81 | + |
| 82 | + set {_error} to "You can only get the midpoint between two locations or two vectors." |
| 83 | + catch runtime errors: |
| 84 | + set {_midpoint} to the midpoint between {_loc} and {_vector} |
| 85 | + assert last caught errors is {_error} with "Midpoint of location variable -> vector variable should error" |
| 86 | + |
| 87 | + catch runtime errors: |
| 88 | + set {_midpoint2} to the midpoint between {_vector} and {_loc} |
| 89 | + assert last caught errors is {_error} with "Midpoint of vector variable -> location variable should error" |
| 90 | + |
| 91 | + catch runtime errors: |
| 92 | + set {_midpoint3} to the midpoint between location(0, 0, 0) and {_vector} |
| 93 | + assert last caught errors is {_error} with "Midpoint of location function -> vector variable should error" |
| 94 | + |
| 95 | + catch runtime errors: |
| 96 | + set {_midpoint4} to the midpoint between {_vector} and location(0, 0, 0) |
| 97 | + assert last caught errors is {_error} with "Midpoint of vector variable -> location function should error" |
| 98 | + |
| 99 | + catch runtime errors: |
| 100 | + set {_midpoint5} to the midpoint between vector(0, 0, 0) and {_loc} |
| 101 | + assert last caught errors is {_error} with "Midpoint of vector function -> location variable should error" |
| 102 | + |
| 103 | + catch runtime errors: |
| 104 | + set {_midpoint6} to the midpoint between {_loc} and vector(0, 0, 0) |
| 105 | + assert last caught errors is {_error} with "Midpoint of location variable -> vector function should error" |
0 commit comments