Skip to content

Commit

Permalink
Tests for all node syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
Moderocky committed May 23, 2024
1 parent 9a6d3cb commit 8c12473
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/test/skript/tests/syntaxes/expressions/ExprConfig.sk
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"
27 changes: 27 additions & 0 deletions src/test/skript/tests/syntaxes/expressions/ExprName.sk
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
using script reflection

test "config name (new)":
set {_node} to the skript config
set {_node} to node "language" of {_node}
assert name of {_node} is "language" with "config node name was wrong"

# node in node
set {_node} to the skript config
set {_node} to node "disable hooks.vault" of {_node}
assert name of {_node} is "vault" with "config node name was wrong"
assert "%{_node}%" is "disable hooks.vault" with "config node path was wrong"

test "node name (new)":
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"

# root node
set {_node} to the skript config
set {_node} to node "language" of {_node}
assert name of {_node} is "language" with "config node name was wrong"

# node in node
set {_node} to the skript config
set {_node} to node "disable hooks.vault" of {_node}
assert name of {_node} is "vault" with "config node name was wrong"
assert "%{_node}%" is "disable hooks.vault" with "config node path was wrong"

test "script name (new)":
set {_name} to the script's name
assert the script's name is "ExprName" with "script name is wrong"
Expand Down
24 changes: 24 additions & 0 deletions src/test/skript/tests/syntaxes/expressions/ExprNode.sk
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 src/test/skript/tests/syntaxes/expressions/ExprNodeValue.sk
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"

0 comments on commit 8c12473

Please sign in to comment.