[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-dev] SF.net SVN: quarks:[2658] CommonTests/TestNoOps.sc



Revision: 2658
          http://sourceforge.net/p/quarks/code/2658
Author:   jrhb
Date:     2013-11-28 11:49:08 +0000 (Thu, 28 Nov 2013)
Log Message:
-----------
some formatting

Modified Paths:
--------------
    CommonTests/TestNoOps.sc

Modified: CommonTests/TestNoOps.sc
===================================================================
--- CommonTests/TestNoOps.sc	2013-11-21 15:49:08 UTC (rev 2657)
+++ CommonTests/TestNoOps.sc	2013-11-28 11:49:08 UTC (rev 2658)
@@ -11,44 +11,44 @@
 	test_array {
 		var ops, check, n = 300;
 		var a, b, r1, r2;
-		
-		
+
+
 		check = { |func, inval|
 			func.value(func.value(inval)) == inval
 		};
-		
+
 		a = Array.rand(300, 0, 100);
 		b = a.clump(10);
-		
+
 		r1 = b.size.rand;
 		r2 = b.size.rand;
-		
+
 		this.assert(n.even, "for this test, array must have even number of elements");
-		
+
 		ops = (
 			\reverse: { |x| x.reverse },
 			\rotate: { |x| x.rotate(x.size div: 2) },
 			\swap: {|x| x.swap(r1, r2) },
 			\flop: {|x| x.flop }
 		);
-		
+
 		ops.keysValuesDo { |name, func|
 			this.assert(check.value(func, b), "the operation '%' should be no-op when applied twice".format(name))
 		};
-		
-		
+
+
 		this.assert(b.flat == a, "flat should return a flat array of the same order");
 		this.assert(b.flatten(1) == a, "flatten should return a flat array of the same order");
 		this.assert(b.sum.sum == a.sum, "summing should be invariant with sub arrays");
-		this.assert({ |...args| args }.flop.value(*b) == b.flop, 
+		this.assert({ |...args| args }.flop.value(*b) == b.flop,
 			"function flop should behave in analogy to array.flop");
 
-		
-			
-		
+
+
+
 	}
-	
-		
+
+
 	test_numerical_homomorphisms {
 		var n = [
 				10.rand2, // integers
@@ -62,27 +62,27 @@
 		var test = { |name, f, h, a, b|
 			var x = f.(h.(a, b));
 			var y = h.(f.(a), f.(b));
-			this.assert(this.deepEval(x) == this.deepEval(y), 
+			this.assert(this.deepEval(x) == this.deepEval(y),
 				name + "should be a homomorphism for" + [a, b]);
 		};
 		var c = 0.5;
-		
+
 		numbers.pairsDo { |n1, n2|
 			test.value("add-mul", c * _, _ + _, n1, n2);
 			test.value("add-div", _ / c, _ + _, n1, n2);			test.value("bubble-mul", _.bubble, _ * _, n1, n2);
 		}
-	
+
 	}
-	
+
 	deepEval { |item|
 		^if(item.isSequenceableCollection) {
 			item.collect(this.deepEval(_))
 		} {
 			item.value
 		}
-	
+
 	}
-	
+
 	assertEqualValue { |a, b, comment, report = true, onFailure|
 		var diff, size;
 		a = a.value;
@@ -91,7 +91,7 @@
 		// faliures with 1e-13 in new build
 		^this.assert(diff < 1e-12, comment, report, { onFailure.value(diff) })
 	}
-	
+
 	test_arithmetics {
 		var n = [
 				rrand(2, 4), // integers
@@ -110,18 +110,18 @@
 				"{|a,b,c| log(a * b) }", "{|a,b,c| log(a) + log(b) }",
 				"{|a,b,c| log(a ** c) }", "{|a,b,c| c * log(a) }"
 		];
-				
+
 		numbers.do { |triple|
 			farmulae.pairsDo { |a, b, i|
 				var x = a.interpret.value(*triple);
 				var y = b.interpret.value(*triple);
-				this.assertEqualValue(x, y, "arithmetic test " ++ i, 
-					onFailure: 
+				this.assertEqualValue(x, y, "arithmetic test " ++ i,
+					onFailure:
 						postf("%\nshould equal close enough\n%\n"
 							"For the values: %\n. Difference: %\n", a, b, triple, _)
 				);
 			};
 		}
 	}
-	
+
 }
\ No newline at end of file

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


_______________________________________________
sc-dev mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-dev/
search: https://listarc.bham.ac.uk/lists/sc-dev/search/