Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Kotlin + JUnit
package hhh.csp
import org.junit.*
import org.junit.rules.ExpectedException
import junit.framework.TestCase
import junit.framework.TestSuite
public class IntervalTest(name :String) : TestCase(name) {
fun testIntervalPlus() {
val values : Array<Interval> = Array(10000,{Interval.zero()});
var v:Interval = Interval.zero();
for( i in values ) i.u = 1.0;
for ( i in values) v = v+i;
println(v);
}
}
class Interval(var l : Double, var u : Double) {
class object {
inline fun zero() = Interval(0.0, 0.0)
}
inline fun clone() = Interval(l,u)
// should be implemented manually
fun plusAssign(other : Interval) {
l += other.l;
u += other.u;
}
// should be implemented automatically
fun plus(other : Interval):Interval {
val v = this.clone()
v.plusAssign(other)
return v
}
inline fun toString() = "[${l}${u}]";
public fun main(args: Array<String> ) {
val values : Array<Interval> = Array<Interval>(10000,{Interval.zero()});
var v:Interval = Interval.zero() + Interval(-1.0,1.0);
for( i in values ) i.u = 1.0;
for ( i in values) v = v + i;
println(v);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.