mirror of
				https://github.com/MontFerret/ferret.git
				synced 2025-10-30 23:37:40 +02:00 
			
		
		
		
	RIGHT() function should return substr counting from right rather than… (#164)
This commit is contained in:
		| @@ -105,5 +105,5 @@ func Right(_ context.Context, args ...core.Value) (core.Value, error) { | ||||
| 		return values.NewString(string(text)), nil | ||||
| 	} | ||||
|  | ||||
| 	return values.NewStringFromRunes(runes[pos:size]), nil | ||||
| 	return values.NewStringFromRunes(runes[size-pos : size]), nil | ||||
| } | ||||
|   | ||||
| @@ -2,10 +2,11 @@ package strings_test | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/MontFerret/ferret/pkg/runtime/values" | ||||
| 	"github.com/MontFerret/ferret/pkg/stdlib/strings" | ||||
| 	. "github.com/smartystreets/goconvey/convey" | ||||
| 	"testing" | ||||
| ) | ||||
|  | ||||
| func TestSubstring(t *testing.T) { | ||||
| @@ -72,10 +73,10 @@ func TestLeft(t *testing.T) { | ||||
| 		}) | ||||
| 	}) | ||||
|  | ||||
| 	Convey("Left('foobar', 3) should return 'foo'", t, func() { | ||||
| 	Convey("Left('foobarfoobar', 3) should return 'foo'", t, func() { | ||||
| 		out, _ := strings.Left( | ||||
| 			context.Background(), | ||||
| 			values.NewString("foobar"), | ||||
| 			values.NewString("foobarfoobar"), | ||||
| 			values.NewInt(3), | ||||
| 		) | ||||
|  | ||||
| @@ -107,10 +108,10 @@ func TestRight(t *testing.T) { | ||||
| 		}) | ||||
| 	}) | ||||
|  | ||||
| 	Convey("Right('foobar', 3) should return 'bar'", t, func() { | ||||
| 	Convey("Right('foobarfoobar', 3) should return 'bar'", t, func() { | ||||
| 		out, _ := strings.Right( | ||||
| 			context.Background(), | ||||
| 			values.NewString("foobar"), | ||||
| 			values.NewString("foobarfoobar"), | ||||
| 			values.NewInt(3), | ||||
| 		) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user