moved all test expression files in the test-resources forlder
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
builtin ["os.file", "base"];
|
||||
|
||||
readInt=func(fh){
|
||||
line=fileRead(fh);
|
||||
line ? [nil] {nil} :: {int(line)}
|
||||
};
|
||||
|
||||
ds={
|
||||
"init":func(filename){
|
||||
fh=fileOpen(filename);
|
||||
fh ? [nil] {nil} :: { @current=readInt(fh); @prev=@current };
|
||||
fh
|
||||
},
|
||||
"current":func(){
|
||||
prev
|
||||
},
|
||||
"next":func(fh){
|
||||
current ?
|
||||
[nil] {current}
|
||||
:: {@prev=current; @current=readInt(fh) but current}
|
||||
},
|
||||
"clean":func(fh){
|
||||
fileClose(fh)
|
||||
}
|
||||
}
|
||||
|
||||
//;f=$(ds, "int.list")
|
||||
/*
|
||||
;f++
|
||||
;f++
|
||||
;f++
|
||||
*/
|
||||
//;add(f)
|
||||
@@ -0,0 +1,18 @@
|
||||
ds={
|
||||
"init":func(end){@end=end; @current=0; @prev=@current},
|
||||
"current":func(){prev},
|
||||
"next":func(){
|
||||
(current <= end) ? [true] {@current=current+1; @prev=current} :: {nil}
|
||||
},
|
||||
"reset":func(){@current=0; @prev=@current}
|
||||
}
|
||||
|
||||
// Example
|
||||
//;
|
||||
//it=$(ds,3);
|
||||
//it++;
|
||||
//it."reset"
|
||||
//it++;
|
||||
//it++;
|
||||
//add(it)
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
sample-export-all.expr: example source file
|
||||
*/
|
||||
|
||||
@@; // Enable export all mode
|
||||
|
||||
// double(x): returns 2*x
|
||||
double=func(x){2*x};
|
||||
|
||||
// Define variable 'a' wth value 5
|
||||
a=5;
|
||||
|
||||
// two(): returns 2
|
||||
two=func() {2};
|
||||
|
||||
// six(): returns 6
|
||||
six=func() {6};
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
test-funcs.expr: example source file
|
||||
*/
|
||||
|
||||
// double(x): returns 2*x
|
||||
@double=func(x){2*x};
|
||||
|
||||
// Define variable 'a' wth value 5
|
||||
@a=5;
|
||||
|
||||
// two(): returns 2
|
||||
@two=func() {2};
|
||||
|
||||
// six(): returns 6
|
||||
six=func() {6};
|
||||
Reference in New Issue
Block a user