-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
61736a2
commit abe97ff
Showing
9 changed files
with
352 additions
and
382 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
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,51 @@ | ||
#[name=anonymous_fn_0, run=interpreter]> | ||
|
||
var $pr = function a() { | ||
test_utils::out("hello"); | ||
}; | ||
|
||
$pr(); | ||
a(); | ||
|
||
--- | ||
|
||
hello | ||
hello | ||
|
||
|
||
#[name=anonymous_fn_1_iife, run=interpreter]> | ||
|
||
(function a() { | ||
test_utils::out("hello"); | ||
})(); | ||
|
||
a(); | ||
|
||
--- | ||
|
||
hello | ||
hello | ||
|
||
|
||
#[name=anonymous_fn_2, run=interpreter]> | ||
|
||
var $pr = function() { | ||
test_utils::out("hello"); | ||
}; | ||
|
||
$pr(); | ||
|
||
--- | ||
|
||
hello | ||
|
||
|
||
#[name=anonymous_fn_3_iife, run=interpreter]> | ||
|
||
(function() { | ||
test_utils::out("hello"); | ||
})(); | ||
|
||
--- | ||
|
||
hello |
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,47 @@ | ||
#[name=higher_order_0, run=interpreter]> | ||
|
||
function f($x, $q) { | ||
$x($q); | ||
}; | ||
|
||
function g($q) { | ||
test_utils::out($q); | ||
}; | ||
|
||
for (var $i = 0; $i < 10; $i = $i + 1) { | ||
f(g, $i); | ||
} | ||
|
||
--- | ||
|
||
0 | ||
1 | ||
2 | ||
3 | ||
4 | ||
5 | ||
6 | ||
7 | ||
8 | ||
9 | ||
|
||
|
||
#[name=higher_order_1, run=interpreter]> | ||
|
||
function makeCounter() { | ||
var $i = 0; | ||
function count() { | ||
$i = $i + 1; | ||
test_utils::out($i); | ||
}; | ||
|
||
return count; | ||
}; | ||
var $count = makeCounter(); | ||
$count(); | ||
$count(); | ||
|
||
--- | ||
|
||
1 | ||
2 |
140 changes: 140 additions & 0 deletions
140
lykiadb-server/tests/interpreter/functions/resolving_read
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,140 @@ | ||
#[name=resolving_read_0, run=interpreter]> | ||
|
||
var $a = "global"; | ||
{ | ||
function showA() { | ||
test_utils::out($a); | ||
}; | ||
|
||
showA(); | ||
var $a = "block"; | ||
showA(); | ||
} | ||
|
||
--- | ||
|
||
global | ||
global | ||
|
||
|
||
#[name=resolving_read_1, run=interpreter]> | ||
|
||
var $a = "global"; | ||
{ | ||
function showA() { | ||
test_utils::out($a); | ||
}; | ||
|
||
showA(); | ||
var $a = "block"; | ||
showA(); | ||
|
||
function showB() { | ||
test_utils::out($a); | ||
}; | ||
|
||
showB(); | ||
} | ||
|
||
--- | ||
|
||
global | ||
global | ||
block | ||
|
||
#[name=resolving_read_2, run=interpreter]> | ||
|
||
{ | ||
var $a = "global"; | ||
{ | ||
function showA() { | ||
test_utils::out($a); | ||
}; | ||
|
||
showA(); | ||
var $a = "block"; | ||
showA(); | ||
} | ||
} | ||
|
||
--- | ||
|
||
global | ||
global | ||
|
||
|
||
#[name=resolve_object, run=interpreter]> | ||
|
||
var $text = 'outer $text'; | ||
|
||
var $a = { | ||
myFun: function() { | ||
function pre_define() { | ||
test_utils::out($text); | ||
}; | ||
pre_define(); | ||
|
||
var $text = 'inner $text'; | ||
|
||
function post_define() { | ||
test_utils::out($text); | ||
}; | ||
post_define(); | ||
} | ||
}; | ||
|
||
$a.myFun(); | ||
|
||
--- | ||
|
||
outer $text | ||
inner $text | ||
|
||
|
||
#[name=resolve_deeper_object, run=interpreter]> | ||
|
||
var $text = 'outer $text'; | ||
|
||
var $a = { | ||
b: { | ||
c0: { | ||
myFun: function() { | ||
function pre_define() { | ||
test_utils::out($text); | ||
}; | ||
pre_define(); | ||
|
||
var $text = 'c0 inner $text'; | ||
|
||
function post_define() { | ||
test_utils::out($text); | ||
}; | ||
post_define(); | ||
} | ||
}, | ||
c1: { | ||
myFun: function() { | ||
function pre_define() { | ||
test_utils::out($text); | ||
}; | ||
pre_define(); | ||
|
||
var $text = 'c1 inner $text'; | ||
|
||
function post_define() { | ||
test_utils::out($text); | ||
}; | ||
post_define(); | ||
} | ||
} | ||
} | ||
}; | ||
$a.b.c0.myFun(); | ||
$a.b.c1.myFun(); | ||
|
||
--- | ||
|
||
outer $text | ||
c0 inner $text | ||
outer $text | ||
c1 inner $text |
61 changes: 61 additions & 0 deletions
61
lykiadb-server/tests/interpreter/functions/resolving_write
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,61 @@ | ||
#[name=resolving_write_0, run=interpreter]> | ||
|
||
var $a = "global"; | ||
{ | ||
function showA() { | ||
test_utils::out($a); | ||
}; | ||
|
||
var $a = "block"; | ||
|
||
function showB() { | ||
test_utils::out($a); | ||
}; | ||
|
||
|
||
showA(); | ||
showB(); | ||
|
||
$a = "test"; | ||
|
||
showA(); | ||
showB(); | ||
} | ||
|
||
--- | ||
|
||
global | ||
block | ||
global | ||
test | ||
|
||
|
||
#[name=resolving_write_1, run=interpreter]> | ||
|
||
var $a = "global"; | ||
{ | ||
var $showA = function() { | ||
test_utils::out($a); | ||
}; | ||
|
||
var $a = "block"; | ||
|
||
var $showB = function() { | ||
test_utils::out($a); | ||
}; | ||
|
||
$showA(); | ||
$showB(); | ||
|
||
$a = "test"; | ||
|
||
$showA(); | ||
$showB(); | ||
} | ||
|
||
--- | ||
|
||
global | ||
block | ||
global | ||
test |
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,31 @@ | ||
#[name=multiple_programs, run=interpreter]> | ||
|
||
function resolvedFirst() { | ||
var $a = "global"; | ||
{ | ||
function showA() { | ||
test_utils::out($a); | ||
}; | ||
|
||
showA(); | ||
var $a = "block"; | ||
showA(); | ||
} | ||
}; | ||
resolvedFirst(); | ||
|
||
--- | ||
|
||
global | ||
global | ||
|
||
--- | ||
|
||
resolvedFirst(); | ||
|
||
--- | ||
|
||
global | ||
global | ||
global | ||
global |
Oops, something went wrong.