Commits

Felix Geller  committed 00f4f48

First attempt at creating a test suite for pattern matching facilities employing the new NS3 Syntax.

TODO: Port individual unit tests for pattern matching facilities from NS2 (includes tests for combinators)

  • Participants
  • Parent commits 32700b7

Comments (0)

Files changed (2)

File PatternMatchingTests.ns3

+Newspeak3
+'Pattern-Matching'
+class PatternMatchingTests usingPlatform: platform testFramework: minitest = NewspeakObject (
+"Tests for Newspeaks pattern matching facilities."|
+	private TestContext = minitest TestContext.
+|)
+(
+class SimplificationTests = TestContext (|
+|)
+(
+class Num of: n = (|
+	val = n.
+|)
+('as yet unclassified'
+match: p = (
+	^ p num: val
+))
+class Product of: l and: r = (|
+	lhs =l.
+	rhs = r.
+|)
+('as yet unclassified'
+match: p = (
+	^ p multiply: lhs with: rhs
+))'as yet unclassified'
+simplify: expr = (
+	^ expr
+		case: <multiply: ?x with: <num: 1>> => [ x ]
+		otherwise: [ expr ]
+)
+testSimpleSimplify = (
+|	three = Num of: 3. 
+	result = simplify: three. |
+	assert: result = three.
+)
+testSimplificationForMultiplicationIdentity = (
+|	lhs = Num of: 3.
+	rhs = Num of: 1.
+	product = Product of: lhs and: rhs.
+	result = simplify: product. |
+	assert: result = lhs.
+)) : ('as yet unclassified'
+TEST_CONTEXT = (
+	
+)))

File PatternMatchingTestsConfiguration.ns3

+Newspeak3
+'Pattern-Matching'
+class PatternMatchingTestsConfiguration packageTestsUsing: ns = NewspeakObject (
+"Runs PatternMatchingTests"|
+	PatternMatchingTests = ns PatternMatchingTests.
+|)
+()