Skip to content

Commit

Permalink
fix(examples,e2e): fix compile and runtime errors (analyzer doesn't c…
Browse files Browse the repository at this point in the history
…heck DI args) caused by latest changes
  • Loading branch information
emil14 committed Dec 15, 2024
1 parent 330a5d2 commit ec41d5a
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 72 deletions.
41 changes: 28 additions & 13 deletions e2e/99_bottles_verbose/main/main.neva
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,28 @@ import { fmt }

def Main(start any) (stop any) {
// we use explicit lock to implement fan-in to printNext2Lines
s Switch<int>, PrintNext2Lines, Lock<int>
s Switch<int>
print_next_2_lines PrintNext2Lines
lock Lock<int>
---
:start -> lock:sig
99 -> lock:data
[lock:data, s:else] -> printNext2Lines
printNext2Lines -> s:data
[lock:data, s:else] -> print_next_2_lines
print_next_2_lines -> s:data
-1 -> s:case[0] -> :stop
}

def PrintNext2Lines(n int) (n int) {
Dec<int>, PrintFirstLine, PrintSecondLine
dec Dec<int>
print_first_line PrintFirstLine
print_second_line PrintSecondLine
---
// printFirstLine and printSecondLine won't work in parallel
// print_first_line and print_second_line won't work in parallel
// because they are in the loop at the level of Main
:n -> printFirstLine:n
printFirstLine:n -> dec:data
dec:res -> printSecondLine:n
printSecondLine:n -> :n
:n -> print_first_line:n
print_first_line:n -> dec:data
dec:res -> print_second_line:n
print_second_line:n -> :n
}

// === First Line ===
Expand All @@ -31,7 +35,12 @@ 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, fmt.Printf, Lock<int>, Panic
s Switch<int>
p1 fmt.Println
p2 fmt.Println
printf fmt.Printf
lock Lock<int>
panic Panic
---
:n -> [s:data, lock:data]

Expand All @@ -45,7 +54,7 @@ def PrintFirstLine(n int) (n int) {
$firstLine1 -> printf:tpl
]

[p1:sig, p2:sig, printf:sig] -> lock:sig
[p1:res, p2:res, printf:sig] -> lock:sig
printf:err -> panic
lock:data -> :n
}
Expand All @@ -58,7 +67,13 @@ 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) {
s Switch<int>, p1 fmt.Println, p2 fmt.Println, p3 fmt.Println, fmt.Printf, Lock<int>, Panic
s Switch<int>
p1 fmt.Println
p2 fmt.Println
p3 fmt.Println
printf fmt.Printf
lock Lock<int>
panic Panic
---
:n -> [s:data, lock:data]

Expand All @@ -75,7 +90,7 @@ def PrintSecondLine(n int) (n int) {
$secondLine1 -> printf:tpl
]

[p1:sig, p2:sig, p3:sig, printf:sig] -> lock:sig
[p1:res, p2:res, p3:res, printf:sig] -> lock:sig
printf:err -> panic
lock:data -> :n
}
30 changes: 17 additions & 13 deletions e2e/add_nums_from_stdin_with_default_any/main/main.neva
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
import { strconv, fmt }

def Main(start any) (stop any) {
Aux, fmt.Println
aux Aux
println fmt.Println
panic Panic
---
:start -> aux:sig
[aux:res, aux:err] -> println:data
println:res -> :stop
:start -> aux:sig
aux:res -> println:data
aux:err -> panic
println:res -> :stop
}

def Aux(sig any) (res int, err error) {
reader1 IntReader
reader2 IntReader
add Add<int>
---
:sig -> reader1:sig
reader1:num -> [add:left, reader2:sig]
:sig -> reader1:sig
reader1:num -> [add:left, reader2:sig]
[reader1:err, reader2:err] -> :err
reader2:num -> add:right
add:res -> :res
reader2:num -> add:right
add:res -> :res
}

def IntReader(sig any) (num int, err error) {
fmt.Scanln, strconv.ParseNum<int>
scanln fmt.Scanln
parse_num strconv.ParseNum<int>
---
:sig -> scanln:res
scanln:res -> parseNum:data
parseNum:res -> :num
parseNum:err -> :err
:sig -> scanln:sig
scanln:res -> parse_num:data
parse_num:res -> :num
parse_num:err -> :err
}
14 changes: 8 additions & 6 deletions e2e/add_nums_from_stdin_with_multuple_senders/main/main.neva
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { strconv, fmt }

def Main(start any) (stop any) {
Aux, fmt.Println<any>
aux Aux,
println fmt.Println<any>
---
:start -> aux:sig
[aux:res, aux:err] -> println:data
Expand All @@ -21,10 +22,11 @@ def Aux(sig any) (res int, err error) {
}

def IntReader(sig any) (num int, err error) {
fmt.Scanln, strconv.ParseNum<int>
scanln fmt.Scanln
parse_num strconv.ParseNum<int>
---
:sig -> scanln:res
scanln:res -> parseNum:data
parseNum:res -> :num
parseNum:err -> :err
:sig -> scanln:sig
scanln:res -> parse_num:data
parse_num:res -> :num
parse_num:err -> :err
}
14 changes: 8 additions & 6 deletions e2e/add_nums_from_stdin_with_sub_components/main/main.neva
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { strconv, fmt }

def Main(start any) (stop any) {
Aux, fmt.Println<any>
aux Aux
println fmt.Println<any>
---
:start -> aux:sig
[aux:res, aux:err] -> println:data
Expand All @@ -21,10 +22,11 @@ def Aux(sig any) (res int, err error) {
}

def IntReader(sig any) (num int, err error) {
fmt.Scanln, strconv.ParseNum<int>
scanln fmt.Scanln
parse_num strconv.ParseNum<int>
---
:sig -> scanln:res
scanln:res -> parseNum:data
parseNum:res -> :num
parseNum:err -> :err
:sig -> scanln:sig
scanln:res -> parse_num:data
parse_num:res -> :num
parse_num:err -> :err
}
6 changes: 3 additions & 3 deletions e2e/echo_verbose/main/main.neva
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { fmt }

def Main(start any) (stop any) {
fmt.Scanln
fmt.Println<string>
scanln fmt.Scanln
println fmt.Println<string>
---
:start -> scanln:res
:start -> scanln:sig
scanln:res -> println:data
println:res -> :stop
}
1 change: 0 additions & 1 deletion e2e/filter_list/neva.yml

This file was deleted.

10 changes: 5 additions & 5 deletions e2e/interface_anonymous/main/main.neva
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { fmt }

def Main(start any) (stop any) {
second_flow Secondflow {fmt.Println<any>}
second_flow Secondflow{fmt.Println<any>}
---
:start -> second_flow:data
second_flow:res -> :stop
}

def Secondflow (data any) (res any) {
iPrinter IPrinter<any>
printer IPrinter<any>
---
:data -> iPrinter:res
iPrinter:sig -> :res
:data -> printer:data
printer:res -> :res
}

interface IPrinter<T>(T) (T)
interface IPrinter<T>(data T) (res T)
10 changes: 5 additions & 5 deletions e2e/interface_verbose/main/main.neva
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import { fmt }

def Main(start any) (stop any) {
second_flow Secondflow {
dep_node fmt.Println<any>
printer fmt.Println<any>
}
---
:start -> second_flow:data
second_flow:res -> :stop
}

def Secondflow (data any) (res any) {
dep_node IPrinter<any>
printer IPrinter<any>
---
:data -> dep_node:res
dep_node:sig -> :res
:data -> printer:data
printer:res -> :res
}

interface IPrinter<T>(T) (T)
interface IPrinter<T>(data T) (res T)
14 changes: 7 additions & 7 deletions e2e/interface_with_imports/main/main.neva
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { github.com/nevalang/x:main }

def Main(start any) (stop any) {
second_flow Secondflow{main.Println<any>}
sub_component SubComponent{main.Println<any>}
---
:start -> second_flow:data
second_flow:res -> :stop
:start -> sub_component:data
sub_component:res -> :stop
}

def Secondflow (data any) (res any) {
def SubComponent(data any) (res any) {
printer IPrinter<any>
---
:data -> printer:res
printer:sig -> :res
:data -> printer:data
printer:res -> :res
}

interface IPrinter<T>(T) (T)
interface IPrinter<T>(data T) (res T)
2 changes: 1 addition & 1 deletion e2e/map_list_verbose/main/main.neva
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const lst list<int> = [50, 30, 20, 100]
def Main(start any) (stop any) {
map_decr Map<int, int>{Dec<int>}
s2l StreamToList<int>
println fmt.Println<int>
println fmt.Println<list<int>>
l2s ListToStream<int>
---
:start -> $lst -> l2s -> map_decr -> s2l -> println -> :stop
Expand Down
14 changes: 7 additions & 7 deletions e2e/slow_iteration_with_map/main/main.neva
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import { time, fmt }
const lst list<int> = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

def Main(start any) (stop any) {
ListToStream<int>
Map<int, int>{Slow}
List<int>
fmt.Println<list<int>>
l2s ListToStream<int>
map Map<int, int>{Slow}
s2l StreamToList<int>
println fmt.Println<list<int>>
---
:start -> $lst -> listToStream -> map -> list -> println -> :stop
:start -> $lst -> l2s -> map -> s2l -> println -> :stop
}

def Slow(data int) (res int) {
time.Delay<int>
Dec<int>
delay time.Delay<int>
dec Dec<int>
---
:data -> delay:data
$time.second -> delay:dur
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
)

func Test(t *testing.T) {
t.Skip("skipping for now") // TODO

err := os.Chdir("..")
require.NoError(t, err)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { fmt }

const lst list<int> = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
const numbers list<int> = [2, 4, 6, 8, 10]

def Main(start any) (stop any) {
l2s ListToStream<int>
list_to_stream1 ListToStream<int>
filter_even Filter<int>{predicate Even}
for_print For<int>{fmt.Println<int>}
wait Wait
---
:start -> $lst -> l2s -> filter_even -> for_print -> wait -> :stop
:start -> $numbers -> list_to_stream1-> filter_even -> for_print -> wait -> :stop
}

def Even(data int) (res bool) {
Expand Down

0 comments on commit ec41d5a

Please sign in to comment.