Kumite (ko͞omiˌtā) is the practice of taking techniques learned from Kata and applying them through the act of freestyle sparring.
You can create a new kumite by providing some initial code and optionally some test cases. From there other warriors can spar with you, by enhancing, refactoring and translating your code. There is no limit to how many warriors you can spar with.
A great use for kumite is to begin an idea for a kata as one. You can collaborate with other code warriors until you have it right, then you can convert it to a kata.
Just testing if an NSArray
can contain actual int
s or only NSNumber
s.
#import <Foundation/Foundation.h>
void testFunction() {
NSMutableArray *myArray = [NSMutableArray array];
[myArray addObject: 1];
[myArray addObject: 2];
[myArray addObject: 3];
for (int i = 0; i < [myArray count]; i++) NSLog(@"%d\n", myArray[i]);
// Invalid - compiles but doesn't give correct values 1, 2, 3
// for (int i = 0; i < [myArray count]; i++) NSLog(@"%@\n", myArray[i]);
NSLog(@"NSArray can indeed store `int`s as-is :D\n");
}
@implementation TestSuite
- (void)testDummy
{
testFunction();
UKTrue(@true);
}
@end
Just confirming that UKIntsEqual
from UnitKit accepts primitive integers as arguments as opposed to NSNumber
.
#import <Foundation/Foundation.h>
@implementation TestSuite
- (void)testDummy
{
UKIntsEqual(2, 1 + 1);
UKIntsNotEqual(2, 1 * 1);
NSLog(@"Yep, UKInts(Not)Equal can accept primitive ints as arguments :D\n");
// Failing
// UKIntsEqual(2, 1 * 1);
// UKIntsNotEqual(1, 1 * 1);
}
@end
Just a simple check to confirm that nested NSArray
s in Objective-C are allowed.
#import <Foundation/Foundation.h>
void testing() {
@[
@[@1, @0, @0],
@[@0, @1, @0],
@[@0, @0, @1]
];
NSLog(@"<PASSED::>Success!\n");
}
@implementation TestSuite
- (void) testNestedNSArrays
{
testing();
}
@end
const text* = "Hello world!"
echo text
test "Check if text is \"Hello world!\"":
check text == "Hello world!"
class Box
attr_accessor :box, :lines, :cols
def initialize cols, lines
@lines = lines
@cols = cols
@box = []
for line in 0...@lines do
row = []
for col in 0...@cols do
isEdge = col == 0 || line == 0 || col == @cols - 1 || line == @lines - 1
row << 'x' if isEdge
row << ' ' unless isEdge
end
@box << row
end
end
def printBox
for line in 0...@lines do
str = ''
for col in 0...@cols do
str << @box[line][col]
end
puts str
end
end
def placeText text, x, y
textLength = text.length - 1 + x
letters = text.split ""
for col in x..textLength do
@box[y][col] = letters[col-x]
end
end
end
box = Box.new 30, 30
box.placeText "Hello World", 10, 10
box.printBox
# TODO: Replace examples and use TDD development by writing your own tests
# These are some of the methods available:
# Test.expect(boolean, [optional] message)
# Test.assert_equals(actual, expected, [optional] message)
# Test.assert_not_equals(actual, expected, [optional] message)
describe "Solution" do
it "should test for something" do
actual = 0
Test.assert_equals(actual, 0, "This is just an example of how you can write your own TDD tests")
end
end
object Adder {
def add(a: Int, b: Int): Int = a + b
}
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest._
import prop._
@RunWith(classOf[JUnitRunner])
class ThinkingAndTesting01Spec extends FunSuite with PropertyChecks with Matchers {
test("Random tests") {
forAll { (a: Int, b: Int) =>
Adder.add(a, b) should be (a + b)
}
}
}
a = "Baguette baguette baguette Encore!"
b = "Baguette baguette baguette Encore!"
p a == b
p a === b
describe "Solution" do
it "should test for something" do
Test.assert_equals(a, b, "equal")
end
end
This my solusion pass the KATA, but it fails on
test generated by rolling 3 elements ASC and DESC arrays.
https://www.codewars.com/kata/simple-array-rotation/ruby
Generating tests:
"ROTATING [1, 10, 100]is ASC"
"rt: 0 ar: [1, 10, 100]is ASC a<b and b<c and a<c"
"rt: 1 ar: [10, 100, 1] ac and a>c"
"ROTATING [100, 10, 1]is DESC"
"rt: 0 ar: [100, 10, 1]is DESC a>b and b>c and a>c"
"rt: 1 ar: [10, 1, 100] a>b and b<c and a<c"
PS:
code for generate tests https://gist.github.com/lbvf50mobile/85f5abb840f3926feb80f7dfe85d2e01
def solve(arr)
return "A" if asc_? arr
return "D" if desc_? arr
if( arr.size == 3)
a = arr
return "RA" if a[0] > a[1] and a[1] < a[2];
end
ch_rd = arr.chunk_while{ |x,y| x > y }.to_a
ch_ra = arr.chunk_while{ |x,y| x < y }.to_a
return "RD" if ch_rd.any?{|x| desc_? x} and ch_rd.size == 2
return "RA" if ch_ra.any?{|x| asc_? x} and ch_ra.size == 2
end
def asc_? arr
arr == arr.sort
end
def desc_? arr
arr == arr.sort.reverse
end
describe "Simple array rotation" do
it "Uncoveder 3 tests" do
Test.assert_equals(solve([10, 100, 1]),"RA")
Test.assert_equals(solve([10, 1, 100]), "RD")
end
end
Compare JS and Ruby REEGEX
RUBY s.scan(/!+|\?+/).inspect
== JS s.match(/!+|\?+/g)
RUBY s.scan(/([?!])\1*/)
!= JS s.match(/([?!])\1*/g)
https://gist.github.com/lbvf50mobile/4b3cd312ad411e47582af40c7cbd4e05/edit
let slot = s => {
console.log("ONE")
console.log("input ", s)
console.log("output" ,s.match(/!+|\?+/g))
console.log("ONE")
console.log("input ", s)
console.log("output", s.match(/([?!])\1*/g))
}
slot("!!!??")