kumi 0.0.26 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/CLAUDE.md +4 -0
  4. data/README.md +17 -8
  5. data/data/functions/core/conversion.yaml +32 -0
  6. data/data/kernels/javascript/core/coercion.yaml +20 -0
  7. data/data/kernels/ruby/core/coercion.yaml +20 -0
  8. data/docs/ARCHITECTURE.md +277 -0
  9. data/docs/DEVELOPMENT.md +62 -0
  10. data/docs/FUNCTIONS.md +955 -0
  11. data/docs/SYNTAX.md +8 -0
  12. data/docs/VSCODE_EXTENSION.md +114 -0
  13. data/docs/functions-reference.json +1821 -0
  14. data/golden/array_element/expected/schema_ruby.rb +1 -1
  15. data/golden/array_index/expected/schema_ruby.rb +1 -1
  16. data/golden/array_operations/expected/schema_ruby.rb +1 -1
  17. data/golden/cascade_logic/expected/schema_ruby.rb +1 -1
  18. data/golden/chained_fusion/expected/schema_ruby.rb +1 -1
  19. data/golden/decimal_explicit/expected/ast.txt +38 -0
  20. data/golden/decimal_explicit/expected/input_plan.txt +3 -0
  21. data/golden/decimal_explicit/expected/lir_00_unoptimized.txt +30 -0
  22. data/golden/decimal_explicit/expected/lir_01_hoist_scalar_references.txt +30 -0
  23. data/golden/decimal_explicit/expected/lir_02_inlined.txt +44 -0
  24. data/golden/decimal_explicit/expected/lir_03_cse.txt +40 -0
  25. data/golden/decimal_explicit/expected/lir_04_1_loop_fusion.txt +40 -0
  26. data/golden/decimal_explicit/expected/lir_04_loop_invcm.txt +40 -0
  27. data/golden/decimal_explicit/expected/lir_06_const_prop.txt +40 -0
  28. data/golden/decimal_explicit/expected/nast.txt +30 -0
  29. data/golden/decimal_explicit/expected/schema_javascript.mjs +31 -0
  30. data/golden/decimal_explicit/expected/schema_ruby.rb +57 -0
  31. data/golden/decimal_explicit/expected/snast.txt +30 -0
  32. data/golden/decimal_explicit/expected.json +1 -0
  33. data/golden/decimal_explicit/input.json +5 -0
  34. data/golden/decimal_explicit/schema.kumi +14 -0
  35. data/golden/element_arrays/expected/schema_ruby.rb +1 -1
  36. data/golden/empty_and_null_inputs/expected/schema_ruby.rb +1 -1
  37. data/golden/function_overload/expected/schema_ruby.rb +1 -1
  38. data/golden/game_of_life/expected/schema_ruby.rb +1 -1
  39. data/golden/hash_keys/expected/schema_ruby.rb +1 -1
  40. data/golden/hash_value/expected/schema_ruby.rb +1 -1
  41. data/golden/hierarchical_complex/expected/schema_ruby.rb +1 -1
  42. data/golden/inline_rename_scope_leak/expected/schema_ruby.rb +1 -1
  43. data/golden/input_reference/expected/schema_ruby.rb +1 -1
  44. data/golden/interleaved_fusion/expected/schema_ruby.rb +1 -1
  45. data/golden/let_inline/expected/schema_ruby.rb +1 -1
  46. data/golden/loop_fusion/expected/schema_ruby.rb +1 -1
  47. data/golden/min_reduce_scope/expected/schema_ruby.rb +1 -1
  48. data/golden/mixed_dimensions/expected/schema_ruby.rb +1 -1
  49. data/golden/multirank_hoisting/expected/schema_ruby.rb +1 -1
  50. data/golden/nested_hash/expected/schema_ruby.rb +1 -1
  51. data/golden/reduction_broadcast/expected/schema_ruby.rb +1 -1
  52. data/golden/roll/expected/schema_ruby.rb +1 -1
  53. data/golden/shift/expected/schema_ruby.rb +1 -1
  54. data/golden/shift_2d/expected/schema_ruby.rb +1 -1
  55. data/golden/simple_math/expected/schema_ruby.rb +1 -1
  56. data/golden/streaming_basics/expected/schema_ruby.rb +1 -1
  57. data/golden/tuples/expected/schema_ruby.rb +1 -1
  58. data/golden/tuples_and_arrays/expected/schema_ruby.rb +1 -1
  59. data/golden/us_tax_2024/expected/schema_ruby.rb +1 -1
  60. data/golden/with_constants/expected/schema_ruby.rb +1 -1
  61. data/lib/kumi/configuration.rb +6 -0
  62. data/lib/kumi/core/input/type_matcher.rb +8 -1
  63. data/lib/kumi/core/ruby_parser/input_builder.rb +2 -2
  64. data/lib/kumi/core/types/normalizer.rb +1 -0
  65. data/lib/kumi/core/types/validator.rb +2 -2
  66. data/lib/kumi/core/types.rb +2 -2
  67. data/lib/kumi/dev/golden/reporter.rb +9 -0
  68. data/lib/kumi/dev/golden/result.rb +3 -1
  69. data/lib/kumi/dev/golden/runtime_test.rb +25 -0
  70. data/lib/kumi/dev/golden/suite.rb +4 -4
  71. data/lib/kumi/dev/golden/value_normalizer.rb +80 -0
  72. data/lib/kumi/dev/golden.rb +21 -12
  73. data/lib/kumi/doc_generator/formatters/json.rb +39 -0
  74. data/lib/kumi/doc_generator/formatters/markdown.rb +175 -0
  75. data/lib/kumi/doc_generator/loader.rb +37 -0
  76. data/lib/kumi/doc_generator/merger.rb +54 -0
  77. data/lib/kumi/doc_generator.rb +4 -0
  78. data/lib/kumi/version.rb +1 -1
  79. data/vscode-extension/.gitignore +4 -0
  80. data/vscode-extension/README.md +59 -0
  81. data/vscode-extension/TESTING.md +151 -0
  82. data/vscode-extension/package.json +51 -0
  83. data/vscode-extension/src/extension.ts +295 -0
  84. data/vscode-extension/tsconfig.json +15 -0
  85. metadata +37 -1
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_1cd98cf56c50f763cab5055e1275d07ac58aaee708cbd081d7773ac43c8d9d33
2
+ module Kumi::Compiled::KUMI_89360babebc3896b16e46cb4cf2f0f8feb3d6f6428e9bf430575b05328fa27eb
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_f0ed06608ce6a4d5050abd38d6642055bd22c10f7ed1ba5c5b32a1c61c78736d
2
+ module Kumi::Compiled::KUMI_1ee54aec6cf6cfd2570cdd73e6ce47bc23c82e4faaf4a03ca6bd11d1e8d34b0e
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_98624b0772f11031b22df384c3c7f33db6dd17485e3f9cf2f69c17ad1d79a9d9
2
+ module Kumi::Compiled::KUMI_0cb193cac7097725954d884c342db7afb7158942e3608106d1d84042f47fb997
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_a359b484890e040a5fdd419b92800fddad006edffc49f277f28525eef4e3d9bd
2
+ module Kumi::Compiled::KUMI_ced9076f56216648b58d9ecbfaf37f152c120ca7fbea32964e0ef891829acbca
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_e5b30cb23c39d5d7959274f41cf2d6a7e4ec0016dc7e19c0bef5c08d67ee1933
2
+ module Kumi::Compiled::KUMI_48491984ea6dc439d6851cae7cc74e9d139f13ab6290dea881bd89a3ee853b3b
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -0,0 +1,38 @@
1
+ (Root
2
+ inputs: [
3
+ (InputDeclaration :unit_price :string)
4
+ (InputDeclaration :quantity :integer)
5
+ (InputDeclaration :tax_rate :string)
6
+ ]
7
+ values: [
8
+ (ValueDeclaration :price
9
+ (CallExpression :to_decimal
10
+ (InputReference :unit_price)
11
+ )
12
+ )
13
+ (ValueDeclaration :rate
14
+ (CallExpression :to_decimal
15
+ (InputReference :tax_rate)
16
+ )
17
+ )
18
+ (ValueDeclaration :subtotal
19
+ (CallExpression :multiply
20
+ (DeclarationReference :price)
21
+ (InputReference :quantity)
22
+ )
23
+ )
24
+ (ValueDeclaration :tax_amount
25
+ (CallExpression :multiply
26
+ (DeclarationReference :subtotal)
27
+ (DeclarationReference :rate)
28
+ )
29
+ )
30
+ (ValueDeclaration :total
31
+ (CallExpression :add
32
+ (DeclarationReference :subtotal)
33
+ (DeclarationReference :tax_amount)
34
+ )
35
+ )
36
+ ]
37
+ traits: []
38
+ )
@@ -0,0 +1,3 @@
1
+ unit_price: string
2
+ quantity: integer
3
+ tax_rate: string
@@ -0,0 +1,30 @@
1
+ (LIR
2
+ (Declaration price
3
+ %t1 = load_input "unit_price" :: string
4
+ %t2 = call core.to_decimal(%t1) :: decimal
5
+ yield %t2
6
+ )
7
+ (Declaration rate
8
+ %t3 = load_input "tax_rate" :: string
9
+ %t4 = call core.to_decimal(%t3) :: decimal
10
+ yield %t4
11
+ )
12
+ (Declaration subtotal
13
+ %t5 = load_decl price :: decimal
14
+ %t6 = load_input "quantity" :: integer
15
+ %t7 = call core.mul(%t5, %t6) :: integer
16
+ yield %t7
17
+ )
18
+ (Declaration tax_amount
19
+ %t8 = load_decl subtotal :: integer
20
+ %t9 = load_decl rate :: decimal
21
+ %t10 = call core.mul(%t8, %t9) :: integer
22
+ yield %t10
23
+ )
24
+ (Declaration total
25
+ %t11 = load_decl subtotal :: integer
26
+ %t12 = load_decl tax_amount :: integer
27
+ %t13 = call core.add(%t11, %t12) :: integer
28
+ yield %t13
29
+ )
30
+ )
@@ -0,0 +1,30 @@
1
+ (LIR
2
+ (Declaration price
3
+ %t1 = load_input "unit_price" :: string
4
+ %t2 = call core.to_decimal(%t1) :: decimal
5
+ yield %t2
6
+ )
7
+ (Declaration rate
8
+ %t3 = load_input "tax_rate" :: string
9
+ %t4 = call core.to_decimal(%t3) :: decimal
10
+ yield %t4
11
+ )
12
+ (Declaration subtotal
13
+ %t5 = load_decl price :: decimal
14
+ %t6 = load_input "quantity" :: integer
15
+ %t7 = call core.mul(%t5, %t6) :: integer
16
+ yield %t7
17
+ )
18
+ (Declaration tax_amount
19
+ %t8 = load_decl subtotal :: integer
20
+ %t9 = load_decl rate :: decimal
21
+ %t10 = call core.mul(%t8, %t9) :: integer
22
+ yield %t10
23
+ )
24
+ (Declaration total
25
+ %t11 = load_decl subtotal :: integer
26
+ %t12 = load_decl tax_amount :: integer
27
+ %t13 = call core.add(%t11, %t12) :: integer
28
+ yield %t13
29
+ )
30
+ )
@@ -0,0 +1,44 @@
1
+ (LIR
2
+ (Declaration price
3
+ %t1 = load_input "unit_price" :: string
4
+ %t2 = call core.to_decimal(%t1) :: decimal
5
+ yield %t2
6
+ )
7
+ (Declaration rate
8
+ %t3 = load_input "tax_rate" :: string
9
+ %t4 = call core.to_decimal(%t3) :: decimal
10
+ yield %t4
11
+ )
12
+ (Declaration subtotal
13
+ %t14 = load_input "unit_price" :: string
14
+ %t15 = call core.to_decimal(%t14) :: decimal
15
+ %t6 = load_input "quantity" :: integer
16
+ %t7 = call core.mul(%t15, %t6) :: integer
17
+ yield %t7
18
+ )
19
+ (Declaration tax_amount
20
+ %t19 = load_input "unit_price" :: string
21
+ %t20 = call core.to_decimal(%t19) :: decimal
22
+ %t17 = load_input "quantity" :: integer
23
+ %t18 = call core.mul(%t20, %t17) :: integer
24
+ %t21 = load_input "tax_rate" :: string
25
+ %t22 = call core.to_decimal(%t21) :: decimal
26
+ %t10 = call core.mul(%t18, %t22) :: integer
27
+ yield %t10
28
+ )
29
+ (Declaration total
30
+ %t26 = load_input "unit_price" :: string
31
+ %t27 = call core.to_decimal(%t26) :: decimal
32
+ %t24 = load_input "quantity" :: integer
33
+ %t25 = call core.mul(%t27, %t24) :: integer
34
+ %t34 = load_input "unit_price" :: string
35
+ %t35 = call core.to_decimal(%t34) :: decimal
36
+ %t32 = load_input "quantity" :: integer
37
+ %t33 = call core.mul(%t35, %t32) :: integer
38
+ %t36 = load_input "tax_rate" :: string
39
+ %t37 = call core.to_decimal(%t36) :: decimal
40
+ %t30 = call core.mul(%t33, %t37) :: integer
41
+ %t13 = call core.add(%t25, %t30) :: integer
42
+ yield %t13
43
+ )
44
+ )
@@ -0,0 +1,40 @@
1
+ (LIR
2
+ (Declaration price
3
+ %t1 = load_input "unit_price" :: string
4
+ %t2 = call core.to_decimal(%t1) :: decimal
5
+ yield %t2
6
+ )
7
+ (Declaration rate
8
+ %t3 = load_input "tax_rate" :: string
9
+ %t4 = call core.to_decimal(%t3) :: decimal
10
+ yield %t4
11
+ )
12
+ (Declaration subtotal
13
+ %t14 = load_input "unit_price" :: string
14
+ %t15 = call core.to_decimal(%t14) :: decimal
15
+ %t6 = load_input "quantity" :: integer
16
+ %t7 = call core.mul(%t15, %t6) :: integer
17
+ yield %t7
18
+ )
19
+ (Declaration tax_amount
20
+ %t19 = load_input "unit_price" :: string
21
+ %t20 = call core.to_decimal(%t19) :: decimal
22
+ %t17 = load_input "quantity" :: integer
23
+ %t18 = call core.mul(%t20, %t17) :: integer
24
+ %t21 = load_input "tax_rate" :: string
25
+ %t22 = call core.to_decimal(%t21) :: decimal
26
+ %t10 = call core.mul(%t18, %t22) :: integer
27
+ yield %t10
28
+ )
29
+ (Declaration total
30
+ %t26 = load_input "unit_price" :: string
31
+ %t27 = call core.to_decimal(%t26) :: decimal
32
+ %t24 = load_input "quantity" :: integer
33
+ %t25 = call core.mul(%t27, %t24) :: integer
34
+ %t36 = load_input "tax_rate" :: string
35
+ %t37 = call core.to_decimal(%t36) :: decimal
36
+ %t30 = call core.mul(%t25, %t37) :: integer
37
+ %t13 = call core.add(%t25, %t30) :: integer
38
+ yield %t13
39
+ )
40
+ )
@@ -0,0 +1,40 @@
1
+ (LIR
2
+ (Declaration price
3
+ %t1 = load_input "unit_price" :: string
4
+ %t2 = call core.to_decimal(%t1) :: decimal
5
+ yield %t2
6
+ )
7
+ (Declaration rate
8
+ %t3 = load_input "tax_rate" :: string
9
+ %t4 = call core.to_decimal(%t3) :: decimal
10
+ yield %t4
11
+ )
12
+ (Declaration subtotal
13
+ %t14 = load_input "unit_price" :: string
14
+ %t15 = call core.to_decimal(%t14) :: decimal
15
+ %t6 = load_input "quantity" :: integer
16
+ %t7 = call core.mul(%t15, %t6) :: integer
17
+ yield %t7
18
+ )
19
+ (Declaration tax_amount
20
+ %t19 = load_input "unit_price" :: string
21
+ %t20 = call core.to_decimal(%t19) :: decimal
22
+ %t17 = load_input "quantity" :: integer
23
+ %t18 = call core.mul(%t20, %t17) :: integer
24
+ %t21 = load_input "tax_rate" :: string
25
+ %t22 = call core.to_decimal(%t21) :: decimal
26
+ %t10 = call core.mul(%t18, %t22) :: integer
27
+ yield %t10
28
+ )
29
+ (Declaration total
30
+ %t26 = load_input "unit_price" :: string
31
+ %t27 = call core.to_decimal(%t26) :: decimal
32
+ %t24 = load_input "quantity" :: integer
33
+ %t25 = call core.mul(%t27, %t24) :: integer
34
+ %t36 = load_input "tax_rate" :: string
35
+ %t37 = call core.to_decimal(%t36) :: decimal
36
+ %t30 = call core.mul(%t25, %t37) :: integer
37
+ %t13 = call core.add(%t25, %t30) :: integer
38
+ yield %t13
39
+ )
40
+ )
@@ -0,0 +1,40 @@
1
+ (LIR
2
+ (Declaration price
3
+ %t1 = load_input "unit_price" :: string
4
+ %t2 = call core.to_decimal(%t1) :: decimal
5
+ yield %t2
6
+ )
7
+ (Declaration rate
8
+ %t3 = load_input "tax_rate" :: string
9
+ %t4 = call core.to_decimal(%t3) :: decimal
10
+ yield %t4
11
+ )
12
+ (Declaration subtotal
13
+ %t14 = load_input "unit_price" :: string
14
+ %t15 = call core.to_decimal(%t14) :: decimal
15
+ %t6 = load_input "quantity" :: integer
16
+ %t7 = call core.mul(%t15, %t6) :: integer
17
+ yield %t7
18
+ )
19
+ (Declaration tax_amount
20
+ %t19 = load_input "unit_price" :: string
21
+ %t20 = call core.to_decimal(%t19) :: decimal
22
+ %t17 = load_input "quantity" :: integer
23
+ %t18 = call core.mul(%t20, %t17) :: integer
24
+ %t21 = load_input "tax_rate" :: string
25
+ %t22 = call core.to_decimal(%t21) :: decimal
26
+ %t10 = call core.mul(%t18, %t22) :: integer
27
+ yield %t10
28
+ )
29
+ (Declaration total
30
+ %t26 = load_input "unit_price" :: string
31
+ %t27 = call core.to_decimal(%t26) :: decimal
32
+ %t24 = load_input "quantity" :: integer
33
+ %t25 = call core.mul(%t27, %t24) :: integer
34
+ %t36 = load_input "tax_rate" :: string
35
+ %t37 = call core.to_decimal(%t36) :: decimal
36
+ %t30 = call core.mul(%t25, %t37) :: integer
37
+ %t13 = call core.add(%t25, %t30) :: integer
38
+ yield %t13
39
+ )
40
+ )
@@ -0,0 +1,40 @@
1
+ (LIR
2
+ (Declaration price
3
+ %t1 = load_input "unit_price" :: string
4
+ %t2 = call core.to_decimal(%t1) :: decimal
5
+ yield %t2
6
+ )
7
+ (Declaration rate
8
+ %t3 = load_input "tax_rate" :: string
9
+ %t4 = call core.to_decimal(%t3) :: decimal
10
+ yield %t4
11
+ )
12
+ (Declaration subtotal
13
+ %t14 = load_input "unit_price" :: string
14
+ %t15 = call core.to_decimal(%t14) :: decimal
15
+ %t6 = load_input "quantity" :: integer
16
+ %t7 = call core.mul(%t15, %t6) :: integer
17
+ yield %t7
18
+ )
19
+ (Declaration tax_amount
20
+ %t19 = load_input "unit_price" :: string
21
+ %t20 = call core.to_decimal(%t19) :: decimal
22
+ %t17 = load_input "quantity" :: integer
23
+ %t18 = call core.mul(%t20, %t17) :: integer
24
+ %t21 = load_input "tax_rate" :: string
25
+ %t22 = call core.to_decimal(%t21) :: decimal
26
+ %t10 = call core.mul(%t18, %t22) :: integer
27
+ yield %t10
28
+ )
29
+ (Declaration total
30
+ %t26 = load_input "unit_price" :: string
31
+ %t27 = call core.to_decimal(%t26) :: decimal
32
+ %t24 = load_input "quantity" :: integer
33
+ %t25 = call core.mul(%t27, %t24) :: integer
34
+ %t36 = load_input "tax_rate" :: string
35
+ %t37 = call core.to_decimal(%t36) :: decimal
36
+ %t30 = call core.mul(%t25, %t37) :: integer
37
+ %t13 = call core.add(%t25, %t30) :: integer
38
+ yield %t13
39
+ )
40
+ )
@@ -0,0 +1,30 @@
1
+ (NAST
2
+ (VALUE price
3
+ (Call :to_decimal
4
+ (InputRef [:unit_price])
5
+ )
6
+ )
7
+ (VALUE rate
8
+ (Call :to_decimal
9
+ (InputRef [:tax_rate])
10
+ )
11
+ )
12
+ (VALUE subtotal
13
+ (Call :multiply
14
+ (Ref price)
15
+ (InputRef [:quantity])
16
+ )
17
+ )
18
+ (VALUE tax_amount
19
+ (Call :multiply
20
+ (Ref subtotal)
21
+ (Ref rate)
22
+ )
23
+ )
24
+ (VALUE total
25
+ (Call :add
26
+ (Ref subtotal)
27
+ (Ref tax_amount)
28
+ )
29
+ )
30
+ )
@@ -0,0 +1,31 @@
1
+ export function _subtotal(input) {
2
+ let t14 = input["unit_price"];
3
+ let t15 = typeof t14 === 'string' ? parseFloat(t14) : Number(t14);
4
+ let t6 = input["quantity"];
5
+ let t7 = t15 * t6;
6
+ return t7;
7
+ }
8
+
9
+ export function _tax_amount(input) {
10
+ let t19 = input["unit_price"];
11
+ let t20 = typeof t19 === 'string' ? parseFloat(t19) : Number(t19);
12
+ let t17 = input["quantity"];
13
+ let t18 = t20 * t17;
14
+ let t21 = input["tax_rate"];
15
+ let t22 = typeof t21 === 'string' ? parseFloat(t21) : Number(t21);
16
+ let t10 = t18 * t22;
17
+ return t10;
18
+ }
19
+
20
+ export function _total(input) {
21
+ let t26 = input["unit_price"];
22
+ let t27 = typeof t26 === 'string' ? parseFloat(t26) : Number(t26);
23
+ let t24 = input["quantity"];
24
+ let t25 = t27 * t24;
25
+ let t36 = input["tax_rate"];
26
+ let t37 = typeof t36 === 'string' ? parseFloat(t36) : Number(t36);
27
+ let t30 = t25 * t37;
28
+ let t13 = t25 + t30;
29
+ return t13;
30
+ }
31
+
@@ -0,0 +1,57 @@
1
+ # Autogenerated by Kumi Codegen
2
+ module Kumi::Compiled::KUMI_da41527c1ad37152fb8c552f2cfddd2f9a3aba7ee79aa824456a153b8517ee5f
3
+ def self.from(input_data = nil)
4
+ instance = Object.new
5
+ instance.extend(self)
6
+ instance.instance_variable_set(:@input, input_data)
7
+ instance
8
+ end
9
+
10
+ def self.__kumi_executable__
11
+ instance = Object.new
12
+ instance.extend(self)
13
+ instance
14
+ end
15
+
16
+ def update(input_data)
17
+ @input = @input.merge(input_data)
18
+ self
19
+ end
20
+
21
+ def [](name)
22
+ case name
23
+ when :subtotal then _subtotal
24
+ when :tax_amount then _tax_amount
25
+ when :total then _total
26
+ else raise KeyError, "Unknown declaration"
27
+ end
28
+ end
29
+
30
+ def _subtotal(input = @input)
31
+ t14 = input["unit_price"] || input[:unit_price]
32
+ t15 = t14.is_a?(BigDecimal) ? t14 : BigDecimal(t14.to_s)
33
+ t6 = input["quantity"] || input[:quantity]
34
+ t15 * t6
35
+ end
36
+
37
+ def _tax_amount(input = @input)
38
+ t19 = input["unit_price"] || input[:unit_price]
39
+ t20 = t19.is_a?(BigDecimal) ? t19 : BigDecimal(t19.to_s)
40
+ t17 = input["quantity"] || input[:quantity]
41
+ t18 = t20 * t17
42
+ t21 = input["tax_rate"] || input[:tax_rate]
43
+ t22 = t21.is_a?(BigDecimal) ? t21 : BigDecimal(t21.to_s)
44
+ t18 * t22
45
+ end
46
+
47
+ def _total(input = @input)
48
+ t26 = input["unit_price"] || input[:unit_price]
49
+ t27 = t26.is_a?(BigDecimal) ? t26 : BigDecimal(t26.to_s)
50
+ t24 = input["quantity"] || input[:quantity]
51
+ t25 = t27 * t24
52
+ t36 = input["tax_rate"] || input[:tax_rate]
53
+ t37 = t36.is_a?(BigDecimal) ? t36 : BigDecimal(t36.to_s)
54
+ t30 = t25 * t37
55
+ t25 + t30
56
+ end
57
+ end
@@ -0,0 +1,30 @@
1
+ (SNAST
2
+ (VALUE price
3
+ (Call :core.to_decimal
4
+ (InputRef unit_price key_chain=[]) :: [] -> string
5
+ ) :: [] -> decimal
6
+ ) :: [] -> decimal
7
+ (VALUE rate
8
+ (Call :core.to_decimal
9
+ (InputRef tax_rate key_chain=[]) :: [] -> string
10
+ ) :: [] -> decimal
11
+ ) :: [] -> decimal
12
+ (VALUE subtotal
13
+ (Call :core.mul
14
+ (Ref price) :: [] -> decimal
15
+ (InputRef quantity key_chain=[]) :: [] -> integer
16
+ ) :: [] -> integer
17
+ ) :: [] -> integer
18
+ (VALUE tax_amount
19
+ (Call :core.mul
20
+ (Ref subtotal) :: [] -> integer
21
+ (Ref rate) :: [] -> decimal
22
+ ) :: [] -> integer
23
+ ) :: [] -> integer
24
+ (VALUE total
25
+ (Call :core.add
26
+ (Ref subtotal) :: [] -> integer
27
+ (Ref tax_amount) :: [] -> integer
28
+ ) :: [] -> integer
29
+ ) :: [] -> integer
30
+ )
@@ -0,0 +1 @@
1
+ {"subtotal": "99.95", "tax_amount": "7.996", "total": "107.946"}
@@ -0,0 +1,5 @@
1
+ {
2
+ "unit_price": "19.99",
3
+ "quantity": 5,
4
+ "tax_rate": "0.08"
5
+ }
@@ -0,0 +1,14 @@
1
+ schema do
2
+ input do
3
+ string :unit_price
4
+ integer :quantity
5
+ string :tax_rate
6
+ end
7
+
8
+ let :price, to_decimal(input.unit_price)
9
+ let :rate, to_decimal(input.tax_rate)
10
+
11
+ value :subtotal, price * input.quantity
12
+ value :tax_amount, subtotal * rate
13
+ value :total, subtotal + tax_amount
14
+ end
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_a2c21afb35a86d67d51bfe12d6bb29d2ef5886500b42431cad974924e3677fa3
2
+ module Kumi::Compiled::KUMI_882cc1d7ef44655567dd97759a39ebfc33efef7825f606e90d0f80a8246099ab
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_ad6e7ee5524d611f2ec03728b7e9f8c097e1308dbaf49da390610067b59c4145
2
+ module Kumi::Compiled::KUMI_2c59ff6fbf5f9f54855ffed7efed5fb3e86a9502ac7b4245f2ecaf6d0965d362
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_fc278e6d9fc513388aad074ca6f0853cd6bfc39df05818173f50fb354060cd30
2
+ module Kumi::Compiled::KUMI_7bfb4d1f4b47bb1aec37b86c3b05a808ae6e13b28cdcac7f03ffeb7624df3532
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_283fb5a79e6f8291e61648873c3f66e10aa9bd5f67c9a7f319663c393389237a
2
+ module Kumi::Compiled::KUMI_ae11e7c3ad9a975bf5a020676cab139ea1236c8dddef854f433710ced5881709
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_12cfcb8020fae57cf986508d88121cdcd8d169a25ea60becdb0375c66241fa37
2
+ module Kumi::Compiled::KUMI_98387d10c8fdfa8747d9dd4e0467343453396c951d55d275edf4af0bbe8b27ef
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_0f694be63aa892525e8879fe071b4a4a2ad55567b0480c5fca002f748a54818d
2
+ module Kumi::Compiled::KUMI_a640fface9d8fd5b448e402d6bf2395566474e3e90386cc2bf6d46017bc09be2
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_1a4593b5476e9c7cc85dedf77f0d089845a959e9f9031f5838efaf26e3bc5486
2
+ module Kumi::Compiled::KUMI_b5eda506631ac67b2fa4e23a5039573b754dbb87a45dd1e8bd18a5dd4c8c97b2
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_148f63c5601013e142e410da768bff3a0570a673ed771762348612e71bedced6
2
+ module Kumi::Compiled::KUMI_b293577e0fe0c4582da8ed3cda757059e40f0fd50edd24bfe36b0d4740df92f1
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_fed43480c1728be2102a0f4594e980fcf8558d62874f4f96c32d502b00ea16ae
2
+ module Kumi::Compiled::KUMI_9c0cff737270bf63de9ce71b67c6290fce449bc31a3d436f78b4b0fc18485ded
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_87ffe0a010684a3e05fc7ee0390ec80c776ceea5e0f6e32d7438702ccd542084
2
+ module Kumi::Compiled::KUMI_babd0dd6c79515b0ea177f8a303874051c0f1c81ff6d57e90002a1cc4a6da663
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_85aba5f3d4113870359ea38cf7c574c50d05d66e700b059e3ca9c29e9d07d912
2
+ module Kumi::Compiled::KUMI_2b17dbaf9b9a1a6c29c795b17daeb9063d83829b4943219762ad8559dc83a981
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_98bd6dd93ae6e80222b0a6d353bac6cc887e2b20924bf5e5cfc392e9aa0b705a
2
+ module Kumi::Compiled::KUMI_c70c48b631574cbfe5b913b29ea93654ff17af9d96ab10931647f10c6c674ef9
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_4d50da3cac1cc57f195f70b5a33c49b41a4b90846c1536c3d767df15b5c72b7a
2
+ module Kumi::Compiled::KUMI_b74a41d0d85c1aa450f7dce23ed22ccfcaf13c330101f5c7ee3f7bc4f4c8b5f4
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_1563f579d65b5974c509af83b7aa99b8e340adf9ec2406de43d1f6278a76a50e
2
+ module Kumi::Compiled::KUMI_a97fe62e81ba9ee34e23cf45b64886d02e7547bbc48b5bebd1869492d71c1aa8
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_c68c448fb7a73dbfec6780905fc3ddcdea1f22e8eacda707f2f8432d4ad79ae0
2
+ module Kumi::Compiled::KUMI_eb3b4d06e6af40ce1803535148d7d8e97065abfc8e4186fd66437ebb384ab54f
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_95f5c5f162bc538a1971324256c0923c4c25ac329f47b44140ea989ce767e3f2
2
+ module Kumi::Compiled::KUMI_ad29cac793fb49736b0ba445da6c4c0761ee9fc79fde4b64eeff0a668781e9a5
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)