(Continuous Integration / Continuous Deployment)
foo <- function(x) {
x <- x*x
x <- 2*x
return(x)
}
test.foo <- function() {
checkTrue(is.numeric(foo(1:10)))
checkEquals(length(foo(1:10)), 10)
checkEqualsNumeric(foo(1), 2)
}
import collection.mutable.Stack
import org.scalatest._
class ExampleSpec extends FlatSpec with Matchers {
"A Stack" should "pop values in last-in-first-out order" in {
val stack = new Stack[Int]
stack.push(1)
stack.push(2)
stack.pop() should be (2)
stack.pop() should be (1)
}
it should "throw NoSuchElementException if an empty stack is popped" in {
val emptyStack = new Stack[Int]
a [NoSuchElementException] should be thrownBy {
emptyStack.pop()
}
}
}
import org.junit.Assert;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
public class AppTest
{
@Test
public void testList()
{
List
list = Arrays.asList("test1","test2");
Assert.assertEquals("test1",list.get(0));
}
}
import test from 'ava';
test('foo', t => {
t.pass();
});
test('bar', async t => {
const bar = Promise.resolve('bar');
t.is(await bar, 'bar');
});
var assert = require('assert');
describe('Array', function() {
describe('#indexOf()', function() {
it('should return -1 when the value is not present', function() {
assert.equal(-1, [1,2,3].indexOf(4));
});
});
});