Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend (E)CL testing #368

Merged
merged 3 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ noao: host core
# Run the test suite.
test:
./test/run_tests
./test/run_tests -c cl.e test/cl.md

# Remove all binaries built. This keeps .x files that were generated
# by generic, xyacc and similar.
Expand Down
2 changes: 1 addition & 1 deletion pkg/cl/unop.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ unop (int opcode)
break;
case OP_NINT:
if (in_type == OT_REAL)
iresult = nearbyint (rval);
iresult = roundl (rval);
else
iresult = ival;
break;
Expand Down
2 changes: 1 addition & 1 deletion pkg/ecl/unop.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ unop (int opcode)
break;
case OP_NINT:
if (in_type == OT_REAL)
iresult = nearbyint (rval);
iresult = roundl (rval);
else
iresult = ival;
break;
Expand Down
3 changes: 2 additions & 1 deletion test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ The following tests are available:
* [Preliminary Test Procedure for IRAF](testproc.md): basic functionality,
mainly from the test procedure document written by Jeanette Barnes and
her "Beginner's Guide to Using IRAF",
* [Programming interface](programming.md) for basic CL and SPP functionality,
* [Command Language](cl.md), and for [ECL extensions](ecl.md)
* [Programming interface](programming.md) for basic SPP functionality,
* [OS specific subroutines](os.md),
* Test from the examples in several packages:
- [`lists`](lists.md),
Expand Down
151 changes: 151 additions & 0 deletions test/cl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# CL scripts

This is based on [An Introductory User’s Guide to IRAF
Scripts](https://iraf-community.github.io/doc/script.pdf) by Ed Anderson.

You will recall that several tasks may be called in sequence on a
single command line, using a semicolon `;` to separate each command.
For example:

```
cl> mkdir database; dir; cd database; dir
database
no files found
```

If the command sequence is too long to fit on a single line, one could
construct a compound statement by using the curly braces, `{}`:

```
cl> {
>>> dir
database
>>> cd database
>>> dir
no files found
>>> }
```

The `>>>` prompt indicates that the CL requires more input (in this
case, the CL is waiting for a `}`) before executing the task or
sequence of tasks. A Terminal Script is essentially a compound
statement, but uses some of the simple programming tools provided by
the CL.

Now we check some control structures. First create a list file with a
`for` loop

File: `loop.cl`
```
for (i = 1; i < 5; i+=1) {
j = i*i
print (i, j, >> "sqr.lis")
}
```

Execute this script and check the content of the list:


```
cl> cl < loop.cl
cl> type "sqr.lis"
1 1
2 4
3 9
4 16
```

Read the file just created with a `while` loop with this script:

File: `while.cl`
```
list = "sqr.lis"
while (fscan(list, i, j) != EOF) print(i, j)
```



```
cl> cl < while.cl
1 1
2 4
3 9
4 16
```

Test intrinsic mathematical CL functions

Test options: `decimals=7`
```
cl> =sin(1.2)
0.9320390859672263
cl> =cos(1.2)
0.3623577544766736
cl> =tan(1.2)
2.5721516221263188
cl> =atan2(2.,3.)
0.5880026035475675
cl> =exp(1.2)
3.3201169227365472
cl> =frac(1.2)
0.2
cl> =int(-1.2)
-1
cl> =log(1.2)
0.1823215567939546
cl> =log10(1.2)
0.07918124604762482
cl> =max(2,3,4,2)
4
cl> =min(2,3,4,2)
2
cl> =mod(123, 7)
4
cl> =nint(1.5)
2
cl> =nint(2.5)
3
cl> =sqrt(1.2)
1.0954451150103321
```

Intrinsic logic functions

```
cl> =real("1.23")
1.23
cl> =isindef(0)
no
cl> =isindef(INDEF)
yes
cl> =radix(123, 10)
123
cl> =radix(123, 16)
7B
cl> =radix(-123, 10)
4294967173
cl> =radix(-123, 16)
FFFFFF85
```

Intrinsic string functions

```
cl> =stridx("fd", "abcdefg")
4
cl> =strldx("fd", "abcdefg")
6
cl> =strlen("abcdefg")
7
cl> =strlstr("def", "abcdefg")
4
cl> =strlwr("aBcDeF")
abcdef
cl> =strstr("def", "abcdefg")
4
cl> =strupr("aBcDeF")
ABCDEF
cl> =substr("abcdefg", 2, 5)
bcde
```

45 changes: 45 additions & 0 deletions test/ecl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Tests specific to ECL

Intrinsic mathematical functions specific for ECL

Test options: `decimals=7`
```
cl> =acos(0.67)
0.8365875393415376
cl> =asin(0.67)
0.7342087874533589
cl> =dacos(0.67)
47.932935197504825
cl> =dasin(0.67)
42.067064802495175
cl> =datan2(2.,3.)
33.690067525979785
cl> =dcos(12.)
0.9781476007338057
cl> =dsin(12.)
0.20791169081775934
cl> =dtan(12.)
0.21255656167002213
cl> =hypot(2.,3.)
3.605551275463989
cl> =deg(1.2)
68.75493541569878
cl> =rad(12)
0.20943951023931956
cl> =sign(-1.2)
-1
cl> =sign(1.2)
1
```

Intrinsic string functions specific for ECL


```
cl> =trim("--abcdefg---", "-")
abcdefg
cl> =triml("--abcdefg---", "-")
abcdefg---
cl> =trimr("--abcdefg---", "-")
--abcdefg
```
77 changes: 1 addition & 76 deletions test/programming.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,6 @@
# Writing own procedures

## CL scripts

This is based on [An Introductory User’s Guide to IRAF
Scripts](https://iraf-community.github.io/doc/script.pdf) by Ed Anderson.

You will recall that several tasks may be called in sequence on a
single command line, using a semicolon `;` to separate each command.
For example:

```
cl> mkdir database; dir; cd database; dir
database
no files found
```

If the command sequence is too long to fit on a single line, one could
construct a compound statement by using the curly braces, `{}`:

```
cl> {
>>> dir
database
>>> cd database
>>> dir
no files found
>>> }
```

The `>>>` prompt indicates that the CL requires more input (in this
case, the CL is waiting for a `}`) before executing the task or
sequence of tasks. A Terminal Script is essentially a compound
statement, but uses some of the simple programming tools provided by
the CL.

Now we check some control structures. First create a list file with a
`for` loop

File: `loop.cl`
```
for (i = 1; i < 5; i+=1) {
j = i*i
print (i, j, >> "sqr.lis")
}
```

Execute this script and check the content of the list:


```
cl> cl < loop.cl
cl> type "sqr.lis"
1 1
2 4
3 9
4 16
```

Read the file just created with a `while` loop with this script:

File: `while.cl`
```
list = "sqr.lis"
while (fscan(list, i, j) != EOF) print(i, j)
```



```
cl> cl < while.cl
1 1
2 4
3 9
4 16
```

# SPP tasks
## SPP tasks

This example is taken from a the [slides of a talk by Rob
Seaman](https://iraf-community.github.io/doc/spp_intro.pdf).
Expand Down