-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #649 from nevalang/std-update
Std update
- Loading branch information
Showing
13 changed files
with
235 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package test | ||
|
||
import ( | ||
"os/exec" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test(t *testing.T) { | ||
cmd := exec.Command("neva", "run", "main") | ||
|
||
out, err := cmd.CombinedOutput() | ||
require.NoError(t, err) | ||
require.Equal( | ||
t, | ||
"false\n", | ||
string(out), | ||
) | ||
|
||
require.Equal(t, 0, cmd.ProcessState.ExitCode()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
component Main(start) (stop) { | ||
nodes { Println, Lt<int>} | ||
:start -> [ | ||
(20 -> lt:compared), | ||
(20 -> lt:actual) | ||
] | ||
lt:res -> println -> :stop | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
neva: 0.23.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import {os,lists } | ||
|
||
component Main(start) (stop) { | ||
nodes { os.Args, lists.For{Println}} | ||
:start -> (args -> for -> :stop) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package funcs | ||
|
||
import ( | ||
"context" | ||
"github.com/nevalang/neva/internal/runtime" | ||
"os" | ||
) | ||
|
||
type args struct{} | ||
|
||
func (a args) Create(io runtime.FuncIO, _ runtime.Msg) (func(ctx context.Context), error) { | ||
outport, err := io.Out.Port("data") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return func(ctx context.Context) { | ||
var lst_args []runtime.Msg | ||
for i := 0; i < len(os.Args); i++ { | ||
lst_args = append(lst_args, runtime.NewStrMsg(os.Args[i])) | ||
} | ||
for { | ||
select { | ||
|
||
case <-ctx.Done(): | ||
return | ||
case outport <- runtime.NewListMsg(lst_args...): | ||
} | ||
} | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package funcs | ||
|
||
import ( | ||
"context" | ||
"github.com/nevalang/neva/internal/runtime" | ||
) | ||
|
||
type floatIsLesser struct{} | ||
|
||
func (p floatIsLesser) Create(io runtime.FuncIO, _ runtime.Msg) (func(ctx context.Context), error) { | ||
actualIn, err := io.In.Port("actual") | ||
if err != nil { | ||
return nil, err | ||
} | ||
comparedIn, err := io.In.Port("compared") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
resOut, err := io.Out.Port("res") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return func(ctx context.Context) { | ||
var ( | ||
val1 runtime.Msg | ||
val2 runtime.Msg | ||
) | ||
|
||
for { | ||
select { | ||
case <-ctx.Done(): | ||
return | ||
case val1 = <-actualIn: | ||
} | ||
|
||
select { | ||
case <-ctx.Done(): | ||
return | ||
case val2 = <-comparedIn: | ||
} | ||
|
||
select { | ||
case <-ctx.Done(): | ||
return | ||
case resOut <- runtime.NewBoolMsg(val1.Int() < val2.Int()): | ||
} | ||
} | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package funcs | ||
|
||
import ( | ||
"context" | ||
"github.com/nevalang/neva/internal/runtime" | ||
) | ||
|
||
type intIsLesser struct{} | ||
|
||
func (p intIsLesser) Create(io runtime.FuncIO, _ runtime.Msg) (func(ctx context.Context), error) { | ||
actualIn, err := io.In.Port("actual") | ||
if err != nil { | ||
return nil, err | ||
} | ||
comparedIn, err := io.In.Port("compared") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
resOut, err := io.Out.Port("res") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return func(ctx context.Context) { | ||
var ( | ||
val1 runtime.Msg | ||
val2 runtime.Msg | ||
) | ||
|
||
for { | ||
select { | ||
case <-ctx.Done(): | ||
return | ||
case val1 = <-actualIn: | ||
} | ||
|
||
select { | ||
case <-ctx.Done(): | ||
return | ||
case val2 = <-comparedIn: | ||
} | ||
|
||
select { | ||
case <-ctx.Done(): | ||
return | ||
case resOut <- runtime.NewBoolMsg(val1.Int() < val2.Int()): | ||
} | ||
} | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package funcs | ||
|
||
import ( | ||
"context" | ||
"github.com/nevalang/neva/internal/runtime" | ||
) | ||
|
||
type strIsLesser struct{} | ||
|
||
func (p strIsLesser) Create(io runtime.FuncIO, _ runtime.Msg) (func(ctx context.Context), error) { | ||
actualIn, err := io.In.Port("actual") | ||
if err != nil { | ||
return nil, err | ||
} | ||
comparedIn, err := io.In.Port("compared") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
resOut, err := io.Out.Port("res") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return func(ctx context.Context) { | ||
var ( | ||
val1 runtime.Msg | ||
val2 runtime.Msg | ||
) | ||
|
||
for { | ||
select { | ||
case <-ctx.Done(): | ||
return | ||
case val1 = <-actualIn: | ||
} | ||
|
||
select { | ||
case <-ctx.Done(): | ||
return | ||
case val2 = <-comparedIn: | ||
} | ||
|
||
select { | ||
case <-ctx.Done(): | ||
return | ||
case resOut <- runtime.NewBoolMsg(val1.Str() < val2.Str()): | ||
} | ||
} | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#extern(scanln) | ||
pub component Scanln(sig any) (data string) | ||
pub component Scanln(sig any) (data string) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#extern(args) | ||
pub component Args() (data list<string>) |