smartcat-labs / ranger

Ranger is contextual data generator used to make sensible data for integration tests or to play with it in the database
https://www.smartcat.io/products/ranger-contextual-data-and-load-generator
Apache License 2.0
59 stars 11 forks source link

Support other primitive types through configuration #166

Closed vajda closed 7 years ago

vajda commented 7 years ago

Problem

Currently, there is only a way to define long and double literals in configuration. This imposes limitation on several things: 1.Other types cannot be used for primitive values

a: 23
b: 234.13

a can only be of type long, but sometimes it is useful to have int, short or byte as a type. b can only be of type double, but sometimes it is useful to have float type as well.

  1. Other types cannot be used in functions
    x: circular(1..250, 1)
    y: random(1.0..100.0)

    There is no way to define those ranges to be of type byte, short, int or float.

Proposed solution

Proposed solution is to use:

byteValue: byte(32)
shortValue: short(14)
explicitIntValue: int(245)
implicitIntValue: 234
longValue: long(38282)
floatValue: float(32.12)
explicitDoubleValue: double(3848.42)
implicitDoubleValue: 8829.123
circularInt: circular(int(12)..int(230), int(1))
randomFloat: random(float(0.0)..float(100.0))

Some unanswered questions:

  1. Should int type be default when using implicit value or should we use long for that?
  2. Should double type be default when using implicit value or should we use float for that?

My votes go to:

  1. Default is int
  2. Default is double

Any other syntax proposal is welcome.

vajda commented 7 years ago

@mgobec, @nivancevic, @nbozic, @milannister, @narezina Care to comment?