import codewars_test as test # TODO Write tests import solution # or from solution import example # test.assert_equals(actual, expected, [optional] message) @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(1 + 1, 2)
- import codewars_test as test
- # TODO Write tests
- import solution # or from solution import example
- # test.assert_equals(actual, expected, [optional] message)
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
- test.assert_equals(1 + 1, 2)
import codewars_test as test # TODO Write tests import solution # or from solution import example # test.assert_equals(actual, expected, [optional] message) @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(a([1, 3]), 4) test.assert_equals(a([1, 52, 40, 30]), 123)
- import codewars_test as test
- # TODO Write tests
- import solution # or from solution import example
- # test.assert_equals(actual, expected, [optional] message)
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
test.assert_equals(add([1, 3]), 4)test.assert_equals(add([1, 52, 40, 30]), 123)- test.assert_equals(a([1, 3]), 4)
- test.assert_equals(a([1, 52, 40, 30]), 123)
Fundamentals
import codewars_test as test # TODO Write tests import solution # or from solution import example @test.it("Basic tests") def basic_tests(): valid = ["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"] # roll 100 times for _ in range(100): result = a() test.expect(result in valid, f"Got {result} but expected one of {valid}")
- import codewars_test as test
- # TODO Write tests
- import solution # or from solution import example
- @test.it("Basic tests")
- def basic_tests():
- valid = ["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"]
- # roll 100 times
- for _ in range(100):
result = d()- result = a()
- test.expect(result in valid, f"Got {result} but expected one of {valid}")
Fundamentals
d=lambda:"⚀"
import random as rclass Dice:def __init__(self, faces):self.faces = r.choice(faces)def __call__(self):return self.facesdice = Dice(["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"])- d=lambda:"⚀"
import codewars_test as test # TODO Write tests import solution # or from solution import example @test.it("Basic tests") def basic_tests(): valid = ["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"] # roll 100 times for _ in range(100): result = d() test.expect(result in valid, f"Got {result} but expected one of {valid}")
- import codewars_test as test
- # TODO Write tests
- import solution # or from solution import example
- @test.it("Basic tests")
- def basic_tests():
- valid = ["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"]
- # roll 100 times
- for _ in range(100):
result = dice()- result = d()
- test.expect(result in valid, f"Got {result} but expected one of {valid}")
Fundamentals
m=(a,b)->a*b+1 {:m}
-- Moonscript!multiply_and_add_one = (a, b) -> a * b + 1{ :multiply_and_add_one }- m=(a,b)->a*b+1
- {:m}
--[=[ import m from require "moon_solution" describe "Multiply and Add One Tests", -> it "Basic tests", -> assert.are.same m(2,3),7 assert.are.same m(4,5),21 assert.are.same m(0,10),1 assert.are.same m(-1,5),-4 --]=] require "setup"
- --[=[
import multiply_and_add_one from require "moon_solution"- import m from require "moon_solution"
- describe "Multiply and Add One Tests", ->
- it "Basic tests", ->
assert.are.same multiply_and_add_one(2, 3), 7assert.are.same multiply_and_add_one(4, 5), 21assert.are.same multiply_and_add_one(0, 10), 1assert.are.same multiply_and_add_one(-1, 5), -4- assert.are.same m(2,3),7
- assert.are.same m(4,5),21
- assert.are.same m(0,10),1
- assert.are.same m(-1,5),-4
- --]=] require "setup"