<commit_before>package match

import (
	"testing"

	"github.com/tisp-lang/tisp/src/lib/ast"
	"github.com/tisp-lang/tisp/src/lib/debug"
)

func TestDesugar(t *testing.T) {
	for _, s := range []interface{}{
		ast.NewLetFunction(
			"factorial",
			ast.NewSignature([]string{"n"}, nil, "", nil, nil, ""),
			nil,
			ast.NewMatch("n", []ast.MatchCase{
				ast.NewMatchCase("0", "1"),
				ast.NewMatchCase(
					"_",
					ast.NewPApp("*",
						[]interface{}{"n", ast.NewPApp(
							"factorial",
							[]interface{}{ast.NewPApp("-", []interface{}{"n", "1"}, debug.NewGoInfo(0))},
							debug.NewGoInfo(0))},
						debug.NewGoInfo(0))),
			}), debug.NewGoInfo(0)),
	} {
		for _, s := range Desugar(s) {
			t.Logf("%#v", s)

			ast.Convert(func(x interface{}) interface{} {
				if _, ok := x.(ast.Match); ok {
					t.Fail()
				}

				return nil
			}, s)<commit_msg>Test match.Desugar function with mutual recursion<commit_after>package match

import (
	"testing"

	"github.com/tisp-lang/tisp/src/lib/ast"
	"github.com/tisp-lang/tisp/src/lib/debug"
)

func TestDesugar(t *testing.T) {
	for _, s := range []interface{}{
		ast.NewLetFunction(
			"factorial",
			ast.NewSignature([]string{"n"}, nil, "", nil, nil, ""),
			nil,
			ast.NewMatch("n", []ast.MatchCase{
				ast.NewMatchCase("0", "1"),
				ast.NewMatchCase(
					"_",
					ast.NewPApp("*",
						[]interface{}{"n", ast.NewPApp(
							"factorial",
							[]interface{}{ast.NewPApp("-", []interface{}{"n", "1"}, debug.NewGoInfo(0))},
							debug.NewGoInfo(0))},
						debug.NewGoInfo(0))),
			}), debug.NewGoInfo(0)),
		ast.NewMutualRecursion([]ast.LetFunction{
			ast.NewLetFunction(
				"even?",
				ast.NewSignature([]string{"n"}, nil, "", nil, nil, ""),
				nil,
				ast.NewMatch("n", []ast.MatchCase{
					ast.NewMatchCase("0", "true"),
					ast.NewMatchCase(
						"_",
						ast.NewPApp(
							"odd?",
							[]interface{}{ast.NewPApp("-", []interface{}{"n", "1"}, debug.NewGoInfo(0))},
							debug.NewGoInfo(0))),
				}), debug.NewGoInfo(0)),
			ast.NewLetFunction(
				"odd?",
				ast.NewSignature([]string{"n"}, nil, "", nil, nil, ""),
				nil,
				ast.NewMatch("n", []ast.MatchCase{
					ast.NewMatchCase("0", "true"),
					ast.NewMatchCase(
						"_",
						ast.NewPApp(
							"even?",
							[]interface{}{ast.NewPApp("-", []interface{}{"n", "1"}, debug.NewGoInfo(0))},
							debug.NewGoInfo(0))),
				}), debug.NewGoInfo(0)),
		}, debug.NewGoInfo(0)),
	} {
		for _, s := range Desugar(s) {
			t.Logf("%#v", s)

			ast.Convert(func(x interface{}) interface{} {
				if _, ok := x.(ast.Match); ok {
					t.Fail()
				}

				return nil
			}, s)
{'fraction_non_alphanumeric': 0.22970903522205208, 'fraction_numerical': 0.009571209800918835, 'mean_word_length': 3.0511627906976746, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '6703808', 'n_tokens_mistral': 1255, 'n_tokens_neox': 988, 'n_words': 152}