{"size": 1410, "ext": "rktl", "max_stars_repo_path": "pkgs/racket-test-core/tests/racket/shared.rktl", "max_stars_repo_name": "lkh01/racket", "max_stars_repo_stars_event_min_datetime": "2018-07-05T21:18:24.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-04T14:48:37.000Z", "max_issues_repo_path": "pkgs/racket-test-core/tests/racket/shared.rktl", "max_issues_repo_name": "lkh01/racket", "max_issues_repo_issues_event_min_datetime": "2017-05-10T07:33:20.000Z", "max_issues_repo_issues_event_max_datetime": "2018-07-19T15:49:46.000Z", "max_forks_repo_path": "pkgs/racket-test-core/tests/racket/shared.rktl", "max_forks_repo_name": "lkh01/racket", "max_forks_repo_forks_event_min_datetime": "2016-04-25T11:47:57.000Z", "max_forks_repo_forks_event_max_datetime": "2017-05-09T14:52:48.000Z"}
{"max_stars_count": 4, "max_issues_count": 9, "max_forks_count": 3, "avg_line_length": 25.6363636364, "max_line_length": 65, "alphanum_fraction": 0.5397163121}

(load-relative "loadtest.rktl")

(Section 'shared)

(require racket/shared
         (prefix-in s: scheme/base)
         racket/undefined)

(define-syntax define-struct
  (syntax-rules ()
    [(_ e (f ...))
     (s:define-struct e (f ...) #:mutable)]
    [(_ e s (f ...))
     (s:define-struct e s (f ...) #:mutable)]))

(load-relative "shared-tests.rktl")

(err/rt-test (shared ([x x]) x) exn:fail:contract:variable?)
(err/rt-test (shared ([x y][y x]) x) exn:fail:contract:variable?)

(test 3 'unbox (shared ([y (box 3)]
                        [x (box (unbox y))])
                 (unbox x)))

(namespace-require/copy 'scheme/base)

(define-syntax define-struct
  (syntax-rules ()
    [(_ e (f ...))
     (s:define-struct e (f ...) #:mutable)]
    [(_ e s (f ...))
     (s:define-struct e s (f ...) #:mutable)]))
(load-relative "shared-tests.rktl")

;; Check that `shared' works with `struct':
(let ()
  (struct a (x y) #:mutable #:transparent)
  (define an-a (a 1 2))
  (set-a-y! an-a an-a)
  (test an-a 'an-a (shared ([t (a 1 t)])
                     t)))

;; Check that `shared' works with auto fields:
(let ()
  (struct a (x y [z #:auto]) #:mutable #:transparent)
  (define an-a (a 1 2))
  (set-a-y! an-a an-a)
  (test an-a 'an-a (shared ([t (a 1 t)])
                     t)))

(test 42 values (shared ((b ((thunk 42)))) b))
(test 42 unbox (shared ((b (box-immutable ((thunk 42))))) b))
(report-errs)
