[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sc-dev] SF.net SVN: quarks:[2658] CommonTests/TestNoOps.sc
- To: sc-dev@xxxxxxxxxxxxxxxx
- Subject: [sc-dev] SF.net SVN: quarks:[2658] CommonTests/TestNoOps.sc
- From: jrhb@xxxxxxxxxxxxxxxxxxxxx
- Date: Thu, 28 Nov 2013 11:49:09 +0000
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:Subject:To:From:MIME-Version:Date; bh=QWeVJMLIPW98LLREPjmFs6byA9QoR6Zl8EdOuvl4GrU=; b=I5OwOTet1HyCw/7c9dRPimSUkNgg7H0B9PFIbWKxepM8NUgb3B/V62iXd236gxLTSlUhLGt8e3Es1cCTAitmJKD801e8/J0o677gITvFyp1YHkr5PSGrWBZ004jFpu/jylGx9R7+G0BvuLsidKCg8tRrUtm8awR+uopQP+DzTwQ=;
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x; h=Content-Transfer-Encoding:Content-Type:Subject:To:From:MIME-Version:Date; bh=QWeVJMLIPW98LLREPjmFs6byA9QoR6Zl8EdOuvl4GrU=; b=sDxa265ivwvxcOfBixHUi2F/3ZeW94V0AAgQvDQiVWAqhKTA9qz1oho82NkfkYvy3z+uc9ZsjAWTmMM8kTihm5bTnk1vTQPETbaQ/GnsGFVJzGAXUh0GRwVQdF2pQXc/JBhJvclSKHn7XA5Lip8bAMAyVT910U1+4qyPALFM9jM=;
- List-id: SuperCollider developers mailing list <sc-devel.create.ucsb.edu>
- Reply-to: sc-dev@xxxxxxxxxxxxxxxx
- Sender: owner-sc-dev@xxxxxxxxxxxxxxxx
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/