Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. defmodule ExkorpionDemo.MathOperationsTest do
  2. use Exkorpion
  3.  
  4. def sum(a,b) do
  5. a + b
  6. end
  7.  
  8. def subs a, b do
  9. a - b
  10. end
  11.  
  12. scenario "testing sum operation works as expected" do
  13.  
  14. it "sum positive numbers works as expected" do
  15. %{
  16. given: fn -> %{a: 1, b: 2} end,
  17.  
  18. when: fn ctx ->
  19. %{c: ctx.a + ctx.b}
  20. end,
  21. then: fn ctx ->
  22. assert ctx.c === 3
  23. end
  24. }
  25. end
  26.  
  27. it "sum negative numbers and it should work as expected" do
  28. %{
  29. given: fn ->
  30. %{a: -1, b: -2}
  31. end,
  32. when: fn ctx ->
  33. %{c: sum(ctx.a, ctx.b)}
  34. end,
  35. then: fn ctx ->
  36. assert ctx.c === -3
  37. end
  38. }
  39. end
  40.  
  41. it "does multiple operations depending on vairable input" do
  42.  
  43. %{
  44. with: fn ->
  45. [
  46. %{param1: 2, param2: 3, result: 5},
  47. %{param1: 3, param2: -2, result: 1}
  48. ]
  49. end,
  50. given: fn ctx ->
  51. %{a: ctx.param1, b: ctx.param2}
  52. end,
  53. when: fn ctx ->
  54. %{c: sum(ctx.a, ctx.b)}
  55. end,
  56. then: fn ctx ->
  57. assert ctx.c === ctx.result
  58. end
  59. }
  60. end
  61.  
  62.  
  63. end
  64.  
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement