<commit_before>package xslt

//import "github.com/moovweb/gokogiri/xml"
//import "unicode/utf8"
import "testing"

func compareStep(t *testing.T, m *MatchStep, op StepOperation, val string) {
	if m.Op != op || val != m.Value {
		t.Error("Expected", op, "=", val, "\nActual  ", m.Op, "=", m.Value)
	}
}

func TestPatternSimple(t *testing.T) {
	steps := parseMatchPattern("test")
	compareStep(t, steps[0], OP_ELEM, "test")
}

func TestPatternParent(t *testing.T) {
	steps := parseMatchPattern("foo/bar")
	compareStep(t, steps[0], OP_ELEM, "bar")
	compareStep(t, steps[1], OP_PARENT, "/")
	compareStep(t, steps[2], OP_ELEM, "foo")
}

func TestPatternRootParent(t *testing.T) {
	steps := parseMatchPattern("/bar")
	compareStep(t, steps[0], OP_ELEM, "bar")
	compareStep(t, steps[1], OP_ROOT, "/")
	compareStep(t, steps[2], OP_END, "")
}

func TestPatternAncestor(t *testing.T) {
	steps := parseMatchPattern("foo//bar")
	compareStep(t, steps[0], OP_ELEM, "bar")
	compareStep(t, steps[1], OP_ANCESTOR, "//")
	compareStep(t, steps[2], OP_ELEM, "foo")
}

func TestPatternRootAncestor(t *testing.T) {
	steps := parseMatchPattern("//bar")
	compareStep(t, steps[0], OP_ELEM, "bar")
	compareStep(t, steps[1], OP_END, "")<commit_msg>Add a match test for the /* pattern<commit_after>package xslt

//import "github.com/moovweb/gokogiri/xml"
//import "unicode/utf8"
import "testing"

func compareStep(t *testing.T, m *MatchStep, op StepOperation, val string) {
	if m.Op != op || val != m.Value {
		t.Error("Expected", op, "=", val, "\nActual  ", m.Op, "=", m.Value)
	}
}

func TestPatternSimple(t *testing.T) {
	steps := parseMatchPattern("test")
	compareStep(t, steps[0], OP_ELEM, "test")
}

func TestPatternParent(t *testing.T) {
	steps := parseMatchPattern("foo/bar")
	compareStep(t, steps[0], OP_ELEM, "bar")
	compareStep(t, steps[1], OP_PARENT, "/")
	compareStep(t, steps[2], OP_ELEM, "foo")
}

func TestPatternRootParent(t *testing.T) {
	steps := parseMatchPattern("/bar")
	compareStep(t, steps[0], OP_ELEM, "bar")
	compareStep(t, steps[1], OP_ROOT, "/")
	compareStep(t, steps[2], OP_END, "")
}

func TestPatternRootWildcard(t *testing.T) {
	steps := parseMatchPattern("/*")
	compareStep(t, steps[0], OP_ALL, "*")
	compareStep(t, steps[1], OP_ROOT, "/")
	compareStep(t, steps[2], OP_END, "")
}

func TestPatternAncestor(t *testing.T) {
	steps := parseMatchPattern("foo//bar")
	compareStep(t, steps[0], OP_ELEM, "bar")
	compareStep(t, steps[1], OP_ANCESTOR, "//")
	compareStep(t, steps[2], OP_ELEM, "foo")
}

func TestPatternRootAncestor(t *testing.T) {
	steps := parseMatchPattern("//bar")
	compareStep(t, steps[0], OP_ELEM, "bar")
	compareStep(t, steps[1], OP_END, "")
{'fraction_non_alphanumeric': 0.19608581106511103, 'fraction_numerical': 0.010914565299209636, 'mean_word_length': 5.562962962962963, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1634227', 'n_tokens_mistral': 1075, 'n_tokens_neox': 1053, 'n_words': 212}