-
-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using script reflection | ||
|
||
test "skript config": | ||
set {_config} to the skript config | ||
assert {_config} exists with "config doesn't exist" | ||
|
||
set {_value} to the boolean value at "color codes reset formatting" in {_config} | ||
assert {_value} exists with "navigation failed" | ||
assert {_value} is true with "colour codes do not reset formatting (direct)" | ||
delete {_value} | ||
|
||
set {_node} to the node "number accuracy" of {_config} | ||
set {_value} to the number value of {_node} | ||
assert {_value} is 2 with "number accuracy wasn't 2 (indirect)" | ||
delete {_value} | ||
|
||
set {_node} to the node "effect command token" of {_config} | ||
set {_value} to the text value of {_node} | ||
assert {_value} is "!" with "effect command token (indirect)" | ||
delete {_value} | ||
|
||
set {_node} to the node "language" of {_config} | ||
set {_value} to the text value of {_node} | ||
assert {_value} is "english" with "language (indirect)" | ||
delete {_value} | ||
|
||
set {_count} to 0 | ||
loop the nodes of {_config}: | ||
add 1 to {_count} | ||
assert {_count} is greater than 10 with "too few nodes in config!" | ||
|
||
test "script config": | ||
set {_config} to the current script | ||
set {_node} to node "test ""script config""" of {_config} | ||
set {_line} to the first element of nodes of {_node} | ||
assert name of {_line} is "set {_config} to the current script" with "our first line was wrong" | ||
|
||
set {_count} to 0 | ||
loop the nodes of {_node}: | ||
add 1 to {_count} | ||
assert {_count} is 7 with "wrong number of lines in this section" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using script reflection | ||
|
||
test "node of": | ||
set {_node} to the current script | ||
set {_node} to the first element of nodes of {_node} | ||
assert name of {_node} is "using script reflection" with "first node name was wrong" | ||
assert "%{_node}%" is "using script reflection" with "first node name was wrong" | ||
assert size of (nodes of {_node}) is 0 with "simple node wasn't empty: %nodes of {_node}%" | ||
|
||
set {_node} to the current script | ||
set {_node} to node "test ""node of""" of {_node} # this :) | ||
assert size of (nodes of {_node}) is greater than 0 with "section node was empty" | ||
|
||
# root node | ||
set {_node} to the skript config | ||
set {_node} to node "language" in {_node} | ||
assert name of {_node} is "language" with "config node name was wrong" | ||
assert text value of {_node} is "english" with "config is in wrong language" | ||
|
||
# node in node | ||
set {_node} to the skript config | ||
set {_node} to node "disable hooks.vault" in {_node} | ||
assert text value of {_node} is "false" with "wrong node text value" | ||
assert boolean value of {_node} is false with "wrong node boolean value" |
30 changes: 30 additions & 0 deletions
30
src/test/skript/tests/syntaxes/expressions/ExprNodeValue.sk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using script reflection | ||
|
||
test "node of": | ||
set {_node} to the current script | ||
set {_node} to the first element of nodes of {_node} | ||
assert text value of {_node} does not exist with "simple node had value?" | ||
|
||
set {_node} to the current script | ||
set {_node} to node "test ""node of""" of {_node} # this :) | ||
assert size of (nodes of {_node}) is greater than 0 with "section node was empty" | ||
|
||
# root node | ||
set {_node} to the skript config | ||
set {_node} to node "language" in {_node} | ||
assert name of {_node} is "language" with "config node name was wrong" | ||
assert text value of {_node} is "english" with "config is in wrong language" | ||
|
||
# node in node | ||
set {_node} to the skript config | ||
set {_node} to node "disable hooks.vault" in {_node} | ||
assert text value of {_node} is "false" with "wrong node text value" | ||
assert boolean value of {_node} is false with "wrong node boolean value" | ||
|
||
# weird type node | ||
set {_node} to node "update check interval" in the skript config | ||
assert text value of {_node} is "12 hours" with "wrong node text value" | ||
set {_time} to {_node}'s timespan value | ||
assert {_time} is 12 hours with "wrong node timespan value" | ||
assert {_time} is greater than 11 hours with "wrong node timespan value" | ||
assert {_time} is less than 13 hours with "wrong node timespan value" |