Skip to the content.

Smoke Tests

Because the documentation is also the test suite it is sometimes necessary to just bang out primitive smoke tests that would clutter the user-facing documentation.

This section is one such. It is a test suite for basic execution paths in pometo_runtime.

Any test failure arising from this documentation will cause a slew of errors across the test suite.

You can stop reading now ;-)

Unitary Negation Smoke Tests

Simple negative integers:

- 1

result it:

¯1

Complex too:

- 1J3

as you would expect:

¯1J¯3

Monadic Branches - Real Numbers Smoke Tests

Scalar first

Not much to see here:

+ 1

but yes it works

1

Now Vectors

Changing gear:

+ 1 2

…the suspense is killing me…

1 2

Different symbol for negation/subtractiona and being negative:

- 1 2

Yup that funny raised negative….

¯1 ¯2

Times is proper times symbol:

× 1 ¯2

giving

1 ¯1

Ditto divide:

÷ 1 2 ¯4

…casts to floats, obvs:

1.0 0.5 ¯0.25

Monadic Branches - Complex Numbers Smoke Tests

This covers mixed vectors and scalars

Complex addition:

+ 1j2 2J¯1

gives:

1J¯2 2J1

And subtraction:

- 1j2 2J¯1

gives:

¯1J¯2 ¯2J1

Times tooL

× 3J4

giving:

0.6J0.8

And old fashioned division:

÷ 3J4
0.12J¯0.16

Dyadic Branches - Real Numbers Smoke Tests

Scalars first

scalars add up:

1 + 2

to a scalar:

3

Now Mixed

scalars can be added to arrays:

1 + 2 3

resulting in a new array:

3 4

This works on both sides:

2 3 + 1

…giving an array of course:

3 4

Now Pure Vectors

Pairwise vector addition

4 5 + 1 2

gives:

5 7

Ditto subtraction:

2 3 - 1 2

gives:

1 1

…and multiplication:

4 5 × 1 2

as you would expect:

4 10

and finally our old pal division:

10 10 ÷ 1 2

with the cast to an array (a vector is just a 1 Dimensional array) of floats

10.0 5.0

Dyadic Branches - Complex Numbers Smoke Tests

Complex addition:

4J2 5J¯1 + 3J3 2J5

as you would expect:

7J5 7J4

and subtraction:

4J2 5J1 - 3J3 2J5

giving:

1J¯1 3J¯4

Dum-dee-dee multiplication:

2J3 × 4j5

works too:

¯7J22

And ending on division:

51j2 ÷ 2j4

Its all good:

5.5J¯10.0

Dyadic Branches - Mixed Real And Complex Numbers Smoke Tests

Mixter maxter addition pairwise both ways:

4J2 5 + 3 2J5

As expected:

7J2 7J5

Similarly subtraction:

4J2 5 - 3 2J5

giving:

1J2 3J¯5

And complex multiplication:

4J2 5 × 3 2J5

gives:

12J6 10J25

And lastly division:

4J2 10 ÷ 2 2J5

where floats go big for us:

2.0J1.0 0.6896551724137931J¯1.7241379310344827

Nested Arrays Smoke Tests

We can nest arrays:

1 2 (3 4)

…and they print boxed:

    ┌───┐
1 2 │3 4│
    └───┘

Mixing Lazy And Eager Vectors Smoke Tests

The default tests set all vectors to either lazy or eager but dyadics need to be tested in mixed mode.

A ← ⎕make_lazy 1 2 3
A + 3 4 5

should give

4 6 8

and

A ← ⎕make_lazy 1 2 3
3 4 5 + A

should give:

4 6 8

Mixing indexed And Unindexed Vectors Smoke Tests

The default tests set all vectors to either indexed or not indexed but dyadics need to be tested in mixed mode.

A ← ⎕make_indexed 1 2 3
A + 3 4 5

should give:

4 6 8

and

A ← ⎕make_indexed 1 2 3
3 4 5 + A

should give

4 6 8

Oddly Shaped Results - Test That Formatter, Baby Smoke Tests

A ← ⍳ 18
2 9 ⍴ A

should give:

 1  2  3  4  5  6  7  8  9
10 11 12 13 14 15 16 17 18

Parsing With Variables

A ← 1 2 3
A 1
1 2 3 1

Variables As Arguments In Function Calls

A ← 1 2 3
⎕print_trees A 2 3
shape: [2]/maybe_func                              
|                                                  
├----------------------------┐                     
|                            |                     
shape: [3]/number            shape: [2]/number     
|                            |                     
├----------------------┬--┐  ├------------------┐  
|                      |  |  |                  |  
1                      2  3  2                  3  
 on line 2 at character 14

plus a lazy AST of course:

shape: unsized_vector/maybe_func                              
|                                                             
├---------------------------------------┐                     
|                                       |                     
shape: unsized_vector/number            shape: [2]/number     
|                                       |                     
├---------------------------------┬--┐  ├------------------┐  
|                                 |  |  |                  |  
1                                 2  3  2                  3  
 on line 2 at character 14

A ← 1 2 3
B ← 4
⎕print_trees A B

We get three different results - the normal one:

shape: [2]/runtime           
|                            
├-------------------------┐  
|                         |  
shape: [3]/number         4  
|                            
├-------------------┬--┐     
|                   |  |     
1                   2  3     
 on line 3 at character 14

the interpreted one:

shape: [2]/maybe_func           
|                               
├----------------------------┐  
|                            |  
shape: [3]/number            4  
|                               
├----------------------┬--┐     
|                      |  |     
1                      2  3     
 on line 3 at character 14

plus a lazy AST of course:

shape: [2]/runtime                     
|                                      
├-----------------------------------┐  
|                                   |  
shape: unsized_vector/number        4  
|                                      
├-----------------------------┬--┐     
|                             |  |     
1                             2  3     
 on line 3 at character 14