v icon indicating copy to clipboard operation
v copied to clipboard

Decision tables support

Open prashanth-hegde opened this issue 3 years ago • 2 comments
trafficstars

There are some situations like the following

  • table-based testing
  • decision tables (https://en.wikipedia.org/wiki/Decision_table)

where it'd be desirable for us to setup a MxN table for processing. Here is an example from go

func TestParseExpression(t *testing.T) {
    testData := []struct {
        name     string
        input    string
        expected string
    }{
        {"base", `results`, `results`},
        {"nested", `results.name`, `results|name`},
        {"padding", `.results.name`, `results|name`},
        {"filter", `results[gender=female]`, `results[gender=female]`},
        {"nestedfilter", `..results[name.title=Miss]`, `results[name.title=Miss]`},
    }
    for _, testcase := range testData {
        output, _ := parseExpression(testcase.input)
        expectedTokens := strings.Split(testcase.expected, "|")
        if !reflect.DeepEqual(expectedTokens, output) {
            t.Errorf("%s --> failed", testcase.name)
        }
    }
}

It'd be nice if v can allow for this to allow building the decision tables inside a fn The idea comes from OOP concepts where an entire behavior (equivalent to a class) can be encapsulated inside a fn

prashanth-hegde avatar Aug 02 '22 20:08 prashanth-hegde

That's obviously Go code - can you provide a link to the full source?

JalonSolov avatar Aug 02 '22 21:08 JalonSolov

sure thing - https://github.com/prashanth-hegde/jpath/blob/main/parser/expr_test.go

prashanth-hegde avatar Aug 02 '22 21:08 prashanth-hegde