| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 | 6 |
| 7 // library abstract_expressions; | 7 // library abstract_expressions; |
| 8 | 8 |
| 9 abstract class AbstractExpression {} | 9 abstract class AbstractExpression {} |
| 10 | 10 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 94 } |
| 95 | 95 |
| 96 // library expressions; | 96 // library expressions; |
| 97 | 97 |
| 98 // import 'abstractExpressions.dart'; | 98 // import 'abstractExpressions.dart'; |
| 99 // import 'evaluator.dart'; | 99 // import 'evaluator.dart'; |
| 100 // import 'multiplication.dart'; | 100 // import 'multiplication.dart'; |
| 101 // import 'multiplicationEvaluator.dart'; | 101 // import 'multiplicationEvaluator.dart'; |
| 102 // import 'stringConverter.dart'; | 102 // import 'stringConverter.dart'; |
| 103 | 103 |
| 104 class Expression = | 104 abstract class Expression = |
| 105 AbstractExpression with ExpressionWithEval, ExpressionWithStringConversion; | 105 AbstractExpression with ExpressionWithEval, ExpressionWithStringConversion; |
| 106 | 106 |
| 107 class Addition = | 107 class Addition = |
| 108 AbstractAddition<Expression> with AdditionWithEval<Expression>, | 108 AbstractAddition<Expression> with AdditionWithEval<Expression>, |
| 109 AdditionWithStringConversion<Expression> imp
lements Expression; | 109 AdditionWithStringConversion<Expression> imp
lements Expression; |
| 110 | 110 |
| 111 class Subtraction = | 111 class Subtraction = |
| 112 AbstractSubtraction<Expression> with SubtractionWithEval<Expression>, | 112 AbstractSubtraction<Expression> with SubtractionWithEval<Expression>, |
| 113 SubtractionWithStringConversion<Expressio
n> implements Expression; | 113 SubtractionWithStringConversion<Expressio
n> implements Expression; |
| 114 | 114 |
| 115 class Number = | 115 class Number = |
| 116 AbstractNumber with NumberWithEval, | 116 AbstractNumber with NumberWithEval, |
| 117 NumberWithStringConversion implements Expression; | 117 NumberWithStringConversion implements Expression; |
| 118 | 118 |
| 119 | 119 |
| 120 class Multiplication = | 120 class Multiplication = |
| 121 AbstractMultiplication<Expression> with MultiplicationWithEval<Expression>, | 121 AbstractMultiplication<Expression> with MultiplicationWithEval<Expression>, |
| 122 MultiplicationWithStringConversion<Exp
ression> implements Expression; | 122 MultiplicationWithStringConversion<Exp
ression> implements Expression; |
| 123 | 123 |
| 124 | 124 |
| 125 void main() { | 125 void main() { |
| 126 Expression e = new Multiplication(new Addition(new Number(4), new Number(2)), | 126 Expression e = new Multiplication(new Addition(new Number(4), new Number(2)), |
| 127 new Subtraction(new Number(10), new Number(7
))); | 127 new Subtraction(new Number(10), new Number(7
))); |
| 128 Expect.equals('((4 + 2)) * (10 - 7)) = 18', '$e = ${e.eval}'); | 128 Expect.equals('((4 + 2)) * (10 - 7)) = 18', '$e = ${e.eval}'); |
| 129 } | 129 } |
| OLD | NEW |