Giter Site home page Giter Site logo

47degrees / scalacheck-toolbox Goto Github PK

View Code? Open in Web Editor NEW
119.0 49.0 7.0 3.69 MB

A helping hand for generating sensible data with ScalaCheck

Home Page: https://47degrees.github.io/scalacheck-toolbox/

License: Apache License 2.0

Scala 100.00%
scalacheck functional-programming jdk8 joda date-time scala

scalacheck-toolbox's Issues

"Illegal instant due to time zone offset transition"

Hi, first of all thanks for saving us the trouble to deal with random date generation.

From time to time we run into an 'Illegal instant due to time zone offset transition' exception due to generating a date which happens to "not exist".

Should be easy to reproduce like this:

import com.fortysevendeg.scalacheck.datetime.joda.ArbitraryJoda._
import org.scalacheck.Arbitrary.arbitrary
import org.joda.time.DateTime

(1 to 10000).map(_ => arbitrary[DateTime].sample)

sometimes results in e.g.

org.joda.time.IllegalInstantException: Illegal instant due to time zone offset transition (daylight savings time 'gap'): 173829578-03-26T02:52:52.521 (Europe/Berlin)
  at org.joda.time.chrono.ZonedChronology.localToUTC(ZonedChronology.java:157)
  at org.joda.time.chrono.ZonedChronology.getDateTimeMillis(ZonedChronology.java:122)
  at org.joda.time.chrono.AssembledChronology.getDateTimeMillis(AssembledChronology.java:133)
  at org.joda.time.base.BaseDateTime.<init>(BaseDateTime.java:257)
  at org.joda.time.base.BaseDateTime.<init>(BaseDateTime.java:198)
  at org.joda.time.DateTime.<init>(DateTime.java:476)
[....]

The link above has more details on the cause and some ideas on mitigating it, though I am not sure what steps would be appropriate in this case to still have completely random dates. Thanks!

ThreetenBP support for dates

Currently, we have JDK 8 time and Joda Time for the Date generators. Are there any plans to support ThreetenBP?

Add Cogen instances

These shouldn't be hard to implement - all we need is a conversion to some concrete representation. For example, for LocalDate we can use Cogen[Long].contramap(_.toEpochDay).

As for the motivation, cats makes extensive use of Cogens in cats-laws.

Filter is failing with ZonedDateTime generator

genZonedDateTime has very big space for year which is preventing strict date formatting like yyyyMMdd.

year <- Gen.choose(-292278994, 292278994)

With above range below filter mostly fails

year <- Gen.choose(-292278994, 292278994) suchThat{r => r.getYear()>1970 && r.getYear()<3000}

I know the range is due to

TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
Timestamp t1 = new Timestamp(Long.MIN_VALUE);
assertEquals("292278994-08-17 07:12:55.192", t1.toString());

However, it is better if library can provide some way to constraint year range for rational generator

Library Logo

Create a logo for the library, prior to releaes

Release for Scala3

We're using the library in tapir, would be great to enable also these tests for Scala3. Thanks!

Got a random test failure in Travis for Scala 2.12

Log message:

[info] ! Java 8 Generators.arbitrary generation with a granularity generates appropriate ZonedDateTimes: Falsified after 58167 passed tests.
[info] > Labels of failing property: 
[info] Hours: +45746443-09-27T04:00+13:45[NZ-CHAT]
[info] > ARG_0: (com.fortysevendeg.scalacheck.datetime.jdk8.granularity.package$$anon$3@2c86bf85,com.fortysevendeg.scalacheck.datetime.jdk8.GenJdk8Properties$$$Lambda$2144/1142872265@35fcbed8)
[info] > ARG_1: +45746443-09-27T04:00+13:45[NZ-CHAT]

Fixes microsite theme

After updating sbt-microsites version up to 1.1.2 the microsite configuration for sbt-microsites should include the micrositeTheme := "pattern" setting to keep the style given when the website was redesign.

TimeZone support

I often have use cases where I need to test dates within a specific time zone. It's probably fairly simple to adapt scalacheck-datetime's Gen instances to my need - just map into it and set the desired timezone - but then I need to make sure this still falls within the expected date boundaries.

Would it be possible to, say, add a new time zone parameter to genDateTimeWithinRange? Might be implicit (probably not a great idea), might have a default value of UTC if you don't want to break backwards compatibility...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.