@Test public void shouldCreateIfAndElseForPattern() { Value pattern = matcher("scotch.test.(empty?)", t(1), arg("#0", t(2)), pattern("scotch.test.(empty?#0)", asList(equal(arg("#0", t(3)), id("[]", t(4)))), literal(true)), pattern("scotch.test.(empty?#1)", asList(ignore(t(9))), literal(false)) ); SymbolGenerator generator = new DefaultSymbolGenerator() {{ startTypesAt(10); }}; assertThat(pattern.reducePatterns(new DefaultPatternReducer(generator)), is(fn("scotch.test.(empty?)", arg("#0", t(2)), conditional( apply( apply(id("scotch.data.eq.(==)", t(10)), arg("#0", t(3)), t(11)), id("[]", t(4)), t(12) ), scope("scotch.test.(empty?#0)", literal(true)), scope("scotch.test.(empty?#1)", literal(false)), t(13) )))); }
private PatternState pattern() { return patterns.peek(); }
DefaultPatternReducer implements PatternReducer { private PatternState pattern() { return patterns.peek(); } }
DefaultPatternReducer implements PatternReducer { private PatternState pattern() { return patterns.peek(); } DefaultPatternReducer(SymbolGenerator generator); }
DefaultPatternReducer implements PatternReducer { private PatternState pattern() { return patterns.peek(); } DefaultPatternReducer(SymbolGenerator generator); @Override void addAssignment(CaptureMatch capture); @Override void addCondition(Value argument, Value value); @Override void addCondition(IsConstructor constructor); @Override void addTaggedArgument(Value taggedArgument); @Override void beginPattern(PatternMatcher matcher); @Override void beginPatternCase(PatternCase patternCase); @Override void endPattern(); @Override void endPatternCase(); @Override Value getTaggedArgument(Value argument); @Override void markFunction(FunctionValue function); @Override Value reducePattern(); }
DefaultPatternReducer implements PatternReducer { private PatternState pattern() { return patterns.peek(); } DefaultPatternReducer(SymbolGenerator generator); @Override void addAssignment(CaptureMatch capture); @Override void addCondition(Value argument, Value value); @Override void addCondition(IsConstructor constructor); @Override void addTaggedArgument(Value taggedArgument); @Override void beginPattern(PatternMatcher matcher); @Override void beginPatternCase(PatternCase patternCase); @Override void endPattern(); @Override void endPatternCase(); @Override Value getTaggedArgument(Value argument); @Override void markFunction(FunctionValue function); @Override Value reducePattern();  }