Skip to content

Commit

Permalink
Expanded tests to cover new cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
smuuf committed Jul 4, 2019
1 parent 7e4f615 commit e04039c
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 2 deletions.
8 changes: 8 additions & 0 deletions tests/language/suites/extensions/ext.bool.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
a:BoolValue:true
b:BoolValue:false
a_1:BoolValue:false
a_2:BoolValue:true
a_3:BoolValue:false
b_1:BoolValue:true
b_2:BoolValue:false
b_3:BoolValue:false
10 changes: 10 additions & 0 deletions tests/language/suites/extensions/ext.bool.primi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
a = true;
b = false;

a_1 = a.not(); // false
a_2 = a.and(true); // true
a_3 = a.and(false); // false

b_1 = b.not(); // true
b_2 = b.and(true); // false
b_3 = b.and(false); // false
9 changes: 9 additions & 0 deletions tests/language/suites/extensions/ext.hash.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
a:StringValue:"79c2b46ce2594ecbcb5b73e928345492"
b:StringValue:"d41d8cd98f00b204e9800998ecf8427e"
c:StringValue:"3f3b08eca62c21d76256e6e1d0b8bf99f4efbe376f64335b72f4163a8fc50dba"
d:StringValue:"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
e:StringValue:"cfcd208495d565ef66e7dff9f98764da"
f:StringValue:"c4ca4238a0b923820dcc509a6f75849b"
EX:Smuuf\Primi\ErrorException
EX:Smuuf\Primi\ErrorException
EX:Smuuf\Primi\ErrorException
12 changes: 12 additions & 0 deletions tests/language/suites/extensions/ext.hash.primi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// pragma:one_liners
a = hash_md5("ahoj");
b = hash_md5("");
c = hash_sha256("ahoj");
d = hash_sha256("");

e = hash_md5(0);
f = hash_md5(1);

_ex = hash_sha256([]);
_ex = hash_sha256(true);
_ex = hash_sha256(null);
2 changes: 2 additions & 0 deletions tests/language/suites/extensions/ext.string.expect
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ k:StringValue:"1 2 3"
l:BoolValue:true
m:BoolValue:true
n:BoolValue:false
o:StringValue:"1,2,3"
p:StringValue:"1,nested,stuff-yeah,3"
7 changes: 5 additions & 2 deletions tests/language/suites/extensions/ext.string.primi
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ j = "{} can now {} strings, {} rascal!".format("you", "format", "you");
k = "{3} {2} {1}".format(3, "2", 1);

l = "if you have a one gigawatt coal plant, you need an eighty car train full of coal every day to provide fuel.".contains("gigawatt");
m = "ahoj ahoj ahoj!".contains(r"(ahoj ){2}!?")
n = "ahoj ahoj ahoj!".contains(r"(čau ){2}!?")
m = "ahoj ahoj ahoj!".contains(r"(ahoj ){2}!?");
n = "ahoj ahoj ahoj!".contains(r"(čau ){2}!?");

o = ",".join([1, 2, 3]);
p = ",".join([1, ['nested', "stuff-{}".format("yeah")], 3]);
14 changes: 14 additions & 0 deletions tests/language/suites/operations/casting.expect
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
type_string_null:StringValue:"null"
type_string_boolA:StringValue:"bool"
type_string_boolB:StringValue:"bool"
type_string_numberA:StringValue:"number"
type_string_numberB:StringValue:"number"
type_string_numberC:StringValue:"number"
type_string_stringA:StringValue:"string"
type_string_stringB:StringValue:"string"
type_string_regexA:StringValue:"regex"
type_string_regexB:StringValue:"regex"
type_string_regexC:StringValue:"regex"
type_string_function:StringValue:"function"
type_string_arrayA:StringValue:"array"
type_string_arrayB:StringValue:"array"
x_number_to_number:NumberValue:1
x_number_to_string:StringValue:"1"
x_number_to_bool:BoolValue:true
Expand Down
15 changes: 15 additions & 0 deletions tests/language/suites/operations/casting.primi
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
// pragma:one_liners
type_string_null = type(null) // "null"
type_string_boolA = type(true) // "bool"
type_string_boolB = type(false) // "bool"
type_string_numberA = type(1) // "number"
type_string_numberB = type(-1) // "number"
type_string_numberC = type(0.123) // "number"
type_string_stringA = type("") // "string"
type_string_stringB = type("ahoj") // "string"
type_string_regexA = type(r"ahoj") // "regex"
type_string_regexB = type(r"a[ho]j") // "regex"
type_string_regexC = type(r"") // "regex"
type_string_function = type(type) // "function"
type_string_arrayA = type([]) // "array"
type_string_arrayB = type([1,2,'c']) // "array"

x_number_to_number = 1.to_number() // 1
x_number_to_string = 1.to_string() // "1"
x_number_to_bool = 1.to_bool() // true
Expand Down
12 changes: 12 additions & 0 deletions tests/language/suites/operations/ex.derefs.inserts.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
EX:Smuuf\Primi\ErrorException
EX:Smuuf\Primi\ErrorException
EX:Smuuf\Primi\ErrorException
EX:Smuuf\Primi\ErrorException
EX:Smuuf\Primi\ErrorException
EX:Smuuf\Primi\ErrorException
EX:Smuuf\Primi\ErrorException
EX:Smuuf\Primi\ErrorException
EX:Smuuf\Primi\ErrorException
EX:Smuuf\Primi\ErrorException
EX:Smuuf\Primi\ErrorException
EX:Smuuf\Primi\ErrorException
28 changes: 28 additions & 0 deletions tests/language/suites/operations/ex.derefs.inserts.primi
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// pragma:one_liners

// Cannot insert arrays into strings.
_tmp = "ahoj"; _tmp[999] = []
// Cannot insert arrays into numbers.
_tmp = 123; _tmp[999] = []
// Cannot insert arrays into bools.
_tmp = true; _tmp[999] = []
// Cannot insert arrays into regexes.
_tmp = r"abc"; _tmp[999] = []

// Cannot insert nulls into strings.
_tmp = "ahoj"; _tmp[999] = null
// Cannot insert nulls into numbers.
_tmp = 123; _tmp[999] = null
// Cannot insert nulls into bools.
_tmp = true; _tmp[999] = null
// Cannot insert nulls into regexes.
_tmp = r"abc"; _tmp[999] = null

// Cannot insert bools into strings.
_tmp = "ahoj"; _tmp[999] = true
// Cannot insert nulls into numbers.
_tmp = 123; _tmp[999] = true
// Cannot insert nulls into bools.
_tmp = true; _tmp[999] = true
// Cannot insert nulls into regexes.
_tmp = r"abc"; _tmp[999] = true

0 comments on commit e04039c

Please sign in to comment.