2024-05-06 05:52:25 +02:00
|
|
|
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
|
|
|
// All rights reserved.
|
|
|
|
|
2024-05-28 07:26:05 +02:00
|
|
|
// t_iterator_test.go
|
2024-05-06 05:52:25 +02:00
|
|
|
package expr
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestIteratorParser(t *testing.T) {
|
|
|
|
inputs := []inputType{
|
2024-06-09 16:01:47 +02:00
|
|
|
/* 1 */ {`include "test-resources/iterator.expr"; it=$(ds,3); ()it`, int64(0), nil},
|
|
|
|
/* 2 */ {`include "test-resources/iterator.expr"; it=$(ds,3); it++; it++`, int64(1), nil},
|
|
|
|
/* 3 */ {`include "test-resources/iterator.expr"; it=$(ds,3); it++; it++; #it`, int64(2), nil},
|
|
|
|
/* 4 */ {`include "test-resources/iterator.expr"; it=$(ds,3); it++; it++; it.reset; ()it`, int64(0), nil},
|
|
|
|
/* 5 */ {`builtin "math.arith"; include "test-resources/iterator.expr"; it=$(ds,3); add(it)`, int64(6), nil},
|
|
|
|
/* 6 */ {`builtin "math.arith"; include "test-resources/iterator.expr"; it=$(ds,3); mul(it)`, int64(0), nil},
|
2024-06-17 09:53:21 +02:00
|
|
|
/* 7 */ {`builtin "math.arith"; include "test-resources/file-reader.expr"; it=$(ds,"test-resources/int.list"); mul(it)`, int64(12000), nil},
|
|
|
|
/* 8 */ {`include "test-resources/file-reader.expr"; it=$(ds,"test-resources/int.list"); it++; it.index`, int64(0), nil},
|
|
|
|
/* 10 */ {`include "test-resources/file-reader.expr"; it=$(ds,"test-resources/int.list"); it.clean`, true, nil},
|
2024-05-06 05:52:25 +02:00
|
|
|
/* 11 */ {`it=$(1,2,3); it++`, int64(1), nil},
|
|
|
|
}
|
|
|
|
// inputs1 := []inputType{
|
|
|
|
// /* 1 */ {`0?{}`, nil, nil},
|
|
|
|
// }
|
|
|
|
parserTest(t, "Iterator", inputs)
|
|
|
|
}
|