Skip to content

Commit

Permalink
fix: multiple fixes in examples and e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
emil14 committed Nov 13, 2024
1 parent 4ac9c05 commit 8a8decf
Show file tree
Hide file tree
Showing 15 changed files with 153 additions and 169 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,16 @@ Hello, World!
If you open `my_awesome_project/src/main.neva` with your favorite IDE you'll see this

```neva
import { fmt }
def Main(start) (stop) {
Println
fmt.Println
---
:start -> { 'Hello, World!' -> println -> :stop }
}
```

The `Main` component has `start` inport and `stop` outport, with a `println` node (instance of stdlib's `Println`). The network after `---` shows: on `start` message, `"Hello, World!"` is sent to `println`, then program terminates via `stop` signal.
The `import { fmt }` statement imports the standard library's `fmt` module which provides common formatting and printing functionality. The `Main` component has `start` inport and `stop` outport, with a `println` node (instance of stdlib's `fmt.Println`). The network after `---` shows: on `start` message, `"Hello, World!"` is sent to `println`, then program terminates via `stop` signal.

### What's Next?

Expand Down
20 changes: 10 additions & 10 deletions e2e/99_bottles_verbose/main/main.neva
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const firstLine2 string = '1 bottle of beer on the wall, 1 bottle of beer.'
const firstLine3 string = 'No more bottles of beer on the wall, no more bottles of beer.'

def PrintFirstLine(n int) (n int) {
s Switch<int>, p1 fmt.Println, p2 fmt.Println, Printf, Lock<int>, Panic
s Switch<int>, p1 fmt.Println, p2 fmt.Println, fmt.Printf, Lock<int>, Panic
---
:n -> [s:data, lock:data]

Expand All @@ -58,19 +58,19 @@ const secondLine3 string = 'Take one down and pass it around, no more bottles of
const secondLine4 string = 'Go to the store and buy some more, 99 bottles of beer on the wall.'

def PrintSecondLine(n int) (n int) {
Switch<int>, p1 fmt.Println, p2 fmt.Println, p3 fmt.Println, Printf, Lock<int>, Panic
s Switch<int>, p1 fmt.Println, p2 fmt.Println, p3 fmt.Println, fmt.Printf, Lock<int>, Panic
---
:n -> [switch:data, lock:data]
:n -> [s:data, lock:data]

-1 -> switch:case[0]
0 -> switch:case[1]
1 -> switch:case[2]
-1 -> s:case[0]
0 -> s:case[1]
1 -> s:case[2]

switch:case[0] -> { $secondLine4 -> p1:data }
switch:case[1] -> { $secondLine3 -> p2:data }
switch:case[2] -> { $secondLine2 -> p3:data }
s:case[0] -> { $secondLine4 -> p1:data }
s:case[1] -> { $secondLine3 -> p2:data }
s:case[2] -> { $secondLine2 -> p3:data }

switch:else -> [
s:else -> [
printf:args[0],
{ $secondLine1 -> printf:tpl }
]
Expand Down
4 changes: 2 additions & 2 deletions e2e/array_inport_holes/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ func Test(t *testing.T) {
out, err := cmd.CombinedOutput()
require.NoError(t, err)

require.Equal(
require.Contains(
t,
"main/main.neva: array inport 'printf:args' is used incorrectly: slot 1 is missing\n",
string(out),
"main/main.neva: array inport 'printf:args' is used incorrectly: slot 1 is missing\n",
)

require.Equal(t, 0, cmd.ProcessState.ExitCode())
Expand Down
4 changes: 2 additions & 2 deletions e2e/array_inport_holes/main/main.neva
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { io }
import { fmt }

def Main(start any) (stop any) {
Printf
fmt.Printf
---
:start -> { '$1 $2 $3' -> printf:tpl }
1 -> printf:args[0]
Expand Down
4 changes: 2 additions & 2 deletions e2e/array_outport_holes/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ func Test(t *testing.T) {
out, err := cmd.CombinedOutput()
require.NoError(t, err)

require.Equal(
require.Contains(
t,
"main/main.neva: array outport 'fanOut:' is used incorrectly: slot 1 is missing\n",
string(out),
"main/main.neva: array outport 'fanOut:data' is used incorrectly: slot 1 is missing\n",
)

require.Equal(t, 0, cmd.ProcessState.ExitCode())
Expand Down
26 changes: 0 additions & 26 deletions e2e/bare_iter_over_list/e2e_test.go

This file was deleted.

10 changes: 0 additions & 10 deletions e2e/bare_iter_over_list/main/main.neva

This file was deleted.

1 change: 0 additions & 1 deletion e2e/bare_iter_over_list/neva.yml

This file was deleted.

4 changes: 2 additions & 2 deletions e2e/duplicate_receiver/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ func Test(t *testing.T) {
out, err := cmd.CombinedOutput()
require.NoError(t, err)

require.Equal(
require.Contains(
t,
"main/main.neva:7:1: port 'println' is used twice\n",
string(out),
"main/main.neva:7:1: port 'println:sig' is used twice\n",
)

require.Equal(t, 0, cmd.ProcessState.ExitCode())
Expand Down
2 changes: 1 addition & 1 deletion examples/map_list/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/require"
)

func Test(t *testing.T) {
func Test(t *testing.T) {
err := os.Chdir("..")
require.NoError(t, err)

Expand Down
1 change: 1 addition & 0 deletions examples/select/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func Test(t *testing.T) {
defer os.Chdir(wd)

for i := 0; i < 100; i++ {
t.Logf("Running iteration %d", i)
cmd := exec.Command("neva", "run", "select")
out, err := cmd.CombinedOutput()
if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions internal/cli/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ func createNevaMod(path string) error {
}

// Create main.neva file
mainNevaContent := `def Main(start) (stop) {
Println
mainNevaContent := `import { fmt }
def Main(start) (stop) {
fmt.Println
---
:start -> { 'Hello, World!' -> println -> :stop }
}`
Expand Down
Loading

0 comments on commit 8a8decf

Please sign in to comment.