mirror of
https://github.com/MontFerret/ferret.git
synced 2025-03-19 21:28:32 +02:00
* Switched to Lab for e2e tests * Switched to binary * Updated lab installation * Updated use of Lab installer * updates * Changed lab installation path * Updated use of installer * Works * Added additional functions * Updated some tests * Updated go.sum * Works * Refactored assertions * Added tests for testing.True * Added tests for testing.None * Added tests for testing.Lte * Added tests for testing.Lt * Added generic consturctor * Added tests for testing.Len * Added tests for testing.Gte * Added tests for testing.Gt * Added tests for testing.False * Added tests for testing.Empty * Added tests for testing.Fail * Added tests for testing.Equal * Added tests for testing.Include * Updated urls in static page tests * Fixed namespace unit tests * Fixed unit test for testing.Len * Updated E2E scripts * Updaes * Updated Chrome in CI/CD * Added e2e for example test click.fql * Added suite cases for example scripts * Updated examples * Updated * Added type assertions * Updated Chrome opts and disabled headers and cookies related tests * Fixed iframes example * Increased timeouts in navigation examples * Updated value example * Updated comments * Disabled cookies examples * Fixed static url * Disabled headers examples * Disabled UA test * Simplified wait logic * Added base testing module * Fixes after codereview * Disabled failing tests
64 lines
1.2 KiB
Go
64 lines
1.2 KiB
Go
package base
|
|
|
|
import "github.com/MontFerret/ferret/pkg/runtime/core"
|
|
|
|
type CompareOperator int
|
|
|
|
const (
|
|
NotEqualOp CompareOperator = 0
|
|
EqualOp CompareOperator = 1
|
|
LessOp CompareOperator = 2
|
|
LessOrEqualOp CompareOperator = 3
|
|
GreaterOp CompareOperator = 4
|
|
GreaterOrEqualOp CompareOperator = 5
|
|
)
|
|
|
|
func (op CompareOperator) String() string {
|
|
switch op {
|
|
case NotEqualOp:
|
|
return "not equal to"
|
|
case EqualOp:
|
|
return "equal to"
|
|
case LessOp:
|
|
return "less than"
|
|
case LessOrEqualOp:
|
|
return "less than or equal to"
|
|
case GreaterOp:
|
|
return "greater than"
|
|
default:
|
|
return "greater than or equal to"
|
|
}
|
|
}
|
|
|
|
func (op CompareOperator) Compare(args []core.Value) (bool, error) {
|
|
err := core.ValidateArgs(args, 2, 3)
|
|
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
actual := args[0]
|
|
expected := args[1]
|
|
|
|
var result bool
|
|
|
|
switch op {
|
|
case NotEqualOp:
|
|
result = actual.Compare(expected) != 0
|
|
case EqualOp:
|
|
result = actual.Compare(expected) == 0
|
|
case LessOp:
|
|
result = actual.Compare(expected) == -1
|
|
case LessOrEqualOp:
|
|
c := actual.Compare(expected)
|
|
result = c == -1 || c == 0
|
|
case GreaterOp:
|
|
result = actual.Compare(expected) == 1
|
|
default:
|
|
c := actual.Compare(expected)
|
|
result = c == 1 || c == 0
|
|
}
|
|
|
|
return result, nil
|
|
}
|