Skip to content

Commit

Permalink
Added all the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Genarito committed Nov 2, 2021
1 parent 721285c commit 9498ba6
Show file tree
Hide file tree
Showing 64 changed files with 542 additions and 0 deletions.
2 changes: 2 additions & 0 deletions DuplicatedImportError/duplicated_imports_simple.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import "tests/importing/tests-files/duplicated_variable_aux_1.ura"
import "tests/importing/tests-files/duplicated_variable_aux_1.ura"
3 changes: 3 additions & 0 deletions DuplicatedKeyError/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# DuplicatedKeyError tests

The entry point tests is the file `duplicated_key.ura` that imports some of the files in this directory.
3 changes: 3 additions & 0 deletions DuplicatedKeyError/duplicated_key.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Both have defined a key called "my_value"
import "tests/importing/tests-files/duplicated_key_aux_1.ura"
import "tests/importing/tests-files/duplicated_key_aux_2.ura"
1 change: 1 addition & 0 deletions DuplicatedKeyError/duplicated_key_aux_1.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
my_value: 10
1 change: 1 addition & 0 deletions DuplicatedKeyError/duplicated_key_aux_2.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
my_value: 10
3 changes: 3 additions & 0 deletions DuplicatedVariableError/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# DuplicatedVariableError tests

The entry point tests are files `duplicated_variable_1.ura` and `duplicated_variable.ura` (this last one imports some of the files in this directory).
3 changes: 3 additions & 0 deletions DuplicatedVariableError/duplicated_variable.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Both have defined a variable called "$my_variable"
import "tests/importing/tests-files/duplicated_variable_aux_1.ura"
import "tests/importing/tests-files/duplicated_variable_aux_2.ura"
1 change: 1 addition & 0 deletions DuplicatedVariableError/duplicated_variable_1.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$a_var: 14\n$a_var: 15
1 change: 1 addition & 0 deletions DuplicatedVariableError/duplicated_variable_aux_1.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$my_variable: 1
1 change: 1 addition & 0 deletions DuplicatedVariableError/duplicated_variable_aux_2.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$my_variable: 2
1 change: 1 addition & 0 deletions FileNotFoundError/file_not_found.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "invalid_file.ura"
3 changes: 3 additions & 0 deletions InvalidIndentationError/different_chars.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
testing:
test: true # Spaces
test_2: false # Tab
7 changes: 7 additions & 0 deletions InvalidIndentationError/invalid_object_indentation.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
user1:
name: "Carlos"
surname: "Gardel"

user2:
name: # INVALID
surname: "Troilo"
5 changes: 5 additions & 0 deletions InvalidIndentationError/more_than_4_difference.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# INVALID as second level has block of 8 spaces as indentation
services:
nginx:
host: "127.0.0.1"
port: 80
2 changes: 2 additions & 0 deletions InvalidIndentationError/not_divisible_by_4.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
testing:
test: true
2 changes: 2 additions & 0 deletions InvalidIndentationError/with_tabs.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
user:
name: "Gura"
1 change: 1 addition & 0 deletions ParseError/invalid_import_1.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "another_file.ura"
1 change: 1 addition & 0 deletions ParseError/invalid_import_2.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "another_file.ura"
1 change: 1 addition & 0 deletions ParseError/invalid_object_1.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
user1:
3 changes: 3 additions & 0 deletions ParseError/invalid_object_2.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test:
"invalid object"
test_2: 5
1 change: 1 addition & 0 deletions ParseError/invalid_variable_definition_1.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$invalid: true
1 change: 1 addition & 0 deletions ParseError/invalid_variable_definition_2.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$invalid: false
1 change: 1 addition & 0 deletions ParseError/invalid_variable_definition_3.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$invalid: null
1 change: 1 addition & 0 deletions ParseError/invalid_variable_definition_4.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$invalid: [ 1, 2, 3]
3 changes: 3 additions & 0 deletions ParseError/invalid_variable_with_object.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# INVALID, objects are not allowed as a variable value
$invalid: user:
name: 'Invalid user'
1 change: 1 addition & 0 deletions ParseError/with_dashes.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
with-dashes: 5
1 change: 1 addition & 0 deletions ParseError/with_dots.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
with.dot: 5
1 change: 1 addition & 0 deletions ParseError/with_quotes.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"with_quotes": 5
1 change: 1 addition & 0 deletions VariableNotDefinedError/variable_not_defined_1.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test: "$false_var"
1 change: 1 addition & 0 deletions VariableNotDefinedError/variable_not_defined_2.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test: $false_var
5 changes: 5 additions & 0 deletions correct/array_in_object.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
model:
columns: [
[ "var1", "str" ],
[ "var2", "str" ]
]
5 changes: 5 additions & 0 deletions correct/array_in_object_trailing_comma.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
model:
columns: [
[ "var1", "str" ],
[ "var2", "str" ],
]
7 changes: 7 additions & 0 deletions correct/basic_string.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$name: "Gura"

str: "I'm a string. \"You can quote me\". Na\bme\tJos\u00E9\nLocation\tSF."
str_2: "I'm a string. \"You can quote me\". Na\bme\tJos\U000000E9\nLocation\tSF."
with_var: "$name is cool"
escaped_var: "\$name is cool"
with_env_var: "$name is $env_var_value cool" # $env_var_value is defined in corresponding test.py
7 changes: 7 additions & 0 deletions correct/bug_trailing_comma.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
foo: [
bar:
baz: [
far: "faz"
],
]
barbaz: "boo"
Empty file added correct/empty.ura
Empty file.
6 changes: 6 additions & 0 deletions correct/empty_object.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# COMMMENT
empty_object: empty



# COMMENT
1 change: 1 addition & 0 deletions correct/empty_object_2.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
empty_object: empty
1 change: 1 addition & 0 deletions correct/empty_object_3.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
empty_object: empty
2 changes: 2 additions & 0 deletions correct/escape_sentence.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Should be interpreted as \t\\h\\i\\i
foo: "\t\h\i\\i"
102 changes: 102 additions & 0 deletions correct/full.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
a_string: "test string"
int1: +99
int2: 42
int3: 0
int4: -17
int5: 1_000
int6: 5_349_221
int7: 53_49_221 # Indian number system grouping
# Hexadecimal with prefix `0x`
hex1: 0xDEADBEEF
hex2: 0xdeadbeef
hex3: 0xdead_beef

# Octal with prefix `0o`
oct1: 0o01234567
oct2: 0o755 # useful for Unix file permissions

# Binary with prefix `0b`
bin1: 0b11010110

# Fractional
flt1: +1.0
flt2: 3.1415
flt3: -0.01

# Exponent
flt4: 5e+22
flt5: 1e06
flt6: -2E-2

# Both
flt7: 6.626e-34
flt8: 224_617.445_991_228

# Infinity
sf1: inf # Positive infinity
sf2: +inf # Positive infinity
sf3: -inf # Negative infinity

# Null
null: null

# Empty objects
empty_single: empty

# Bool
bool1: true
bool2: false

# Digits as key
1234: "1234"

# Object
services:
nginx:
host: "127.0.0.1"
port: 80

apache:
virtual_host: "10.10.10.4"
port: 81

# Arrays
integers: [ 1, 2, 3 ]
colors: [ "red", "yellow", "green" ]
nested_arrays_of_ints: [ [ 1, 2 ], [3, 4, 5] ]
nested_mixed_array: [ [ 1, 2 ], ["a", "b", "c"] ]

# Mixed-type arrays
numbers: [ 0.1, 0.2, 0.5, 1, 2, 5 ]
tango_singers: [
user1:
name: "Carlos"
surname: "Gardel"
year_of_birth: 1890,
user2:
name: "Aníbal"
surname: "Troilo"
year_of_birth: 1914
]

integers2: [
1, 2, 3
]

integers3: [
1,
2, # Trailing comma
]


$my_string_var: "127.0.0.1"
$my_integer_var: 8080

my_server:
host: $my_string_var
empty_nested: empty
port: $my_integer_var
native_auth: true

$name: "Gura"
gura_is_cool: "$name is cool"
5 changes: 5 additions & 0 deletions correct/importing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Importing tests

This folder contains related tests of [Gura imports functionality][imports]. The entry points are the files `normal.ura` and `with_variable` that import the other files in this directory.

[imports]: https://gura.netlify.app/docs/spec#imports
5 changes: 5 additions & 0 deletions correct/importing/normal.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import "tests/importing/tests-files/one.ura"
import "tests/importing/tests-files/two.ura"

from_original_1: [1, 2, 5]
from_original_2: false
4 changes: 4 additions & 0 deletions correct/importing/one.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import "three.ura"

from_file_one: 1

1 change: 1 addition & 0 deletions correct/importing/three.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from_file_three: true
5 changes: 5 additions & 0 deletions correct/importing/two.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

from_file_two:
name: "Aníbal"
surname: "Troilo"
year_of_birth: 1914
7 changes: 7 additions & 0 deletions correct/importing/with_variable.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$common_path: "tests/importing/tests-files"

import "$common_path/one.ura"
import "$common_path/two.ura"

from_original_1: [1, 2, 5]
from_original_2: false
7 changes: 7 additions & 0 deletions correct/literal_string.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# What you see is what you get.
winpath: 'C:\Users\nodejs\templates'
winpath2: '\\ServerX\admin$\system32\'
quoted: 'John "Dog lover" Wick'
regex: '<\i\c*\s*>'
with_var: '$no_parsed variable!'
escaped_var: '$name is cool'
35 changes: 35 additions & 0 deletions correct/multiline_basic_string.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
$roses: "Roses"

str: """
Roses are red
Violets are blue"""

str_2: """Roses are red
Violets are blue"""

str_3: """Roses are red\nViolets are blue"""

with_var: """
$roses are red
Violets are blue"""

with_env_var: """$env_var_value_multiline are red\nViolets are blue""" # $env_var_value_multiline is defined in corresponding test.py


str_with_backslash: """
The quick brown \


fox jumps over \
the lazy dog."""

str_with_backslash_2: """\
The quick brown \
fox jumps over \
the lazy dog.\
"""

str_4: """Here are two quotation marks: "". Simple enough."""
str_5: """Here are three quotation marks: ""\"."""
str_6: """Here are fifteen quotation marks: ""\"""\"""\"""\"""\"."""
escaped_var: """\$name is cool"""
9 changes: 9 additions & 0 deletions correct/multiline_literal_string.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
regex2: '''I [dw]on't need \d{2} apples'''
lines: '''
The first newline is
trimmed in raw strings.
All other whitespace
is preserved.
'''
with_var: '''$no_parsed variable!'''
escaped_var: '''$name is cool'''
4 changes: 4 additions & 0 deletions correct/nan.ura
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Not a number
sf4: nan
sf5: +nan
sf6: -nan
Loading

0 comments on commit 9498ba6

Please sign in to comment.