61890b15cb
* wip * move print and JSON functions to modules * builtin functions are not replacable now * builtin functions are added for default nil symbol table * importables: builtin modules and source modules * refactoring runtime tests * fix tests * update documentation * cleanup * clean up cli * fix REPL prints
18 lines
506 B
Go
18 lines
506 B
Go
package runtime_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/d5/tengo/objects"
|
|
)
|
|
|
|
func TestBytes(t *testing.T) {
|
|
expect(t, `out = bytes("Hello World!")`, nil, []byte("Hello World!"))
|
|
expect(t, `out = bytes("Hello") + bytes(" ") + bytes("World!")`, nil, []byte("Hello World!"))
|
|
|
|
// bytes[] -> int
|
|
expect(t, `out = bytes("abcde")[0]`, nil, 97)
|
|
expect(t, `out = bytes("abcde")[1]`, nil, 98)
|
|
expect(t, `out = bytes("abcde")[4]`, nil, 101)
|
|
expect(t, `out = bytes("abcde")[10]`, nil, objects.UndefinedValue)
|
|
}
|