*** Settings ***
Documentation    Test RAS sanity scenarios.

Resource        ../../lib/openbmc_ffdc.robot
Resource        ../../lib/openbmc_ffdc_utils.robot
Resource        ../../lib/openbmc_ffdc_methods.robot
Resource        ../../lib/ras/host_utils.robot
Resource        ../../openpower/ras/ras_utils.robot
Library         ../../lib/utils.py
Variables       ../../lib/ras/variables.py
Variables       ../../data/variables.py

Suite Setup      Redfish Power On
Test Setup       Printn
Test Teardown    FFDC On Test Case Fail

*** Variables ***
${proc_chip_id}    0

# mention count to read system memory.
${count}           128

*** Test Cases ***

Test BMC Getscom
    ${value}=  Get From Dictionary  ${ERROR_INJECT_DICT}  MCACALIFIR_RECV1
    Pdbg  -p${proc_chip_id} getscom 0x${value[0]}

Test BMC Getcfam
    Pdbg  -p${proc_chip_id} getcfam 0x${cfam_address}

Test BMC Getmem
    Pdbg  -p${proc_chip_id} getmem 0x${mem_address} ${count}

Update test documentation and tags as per guidelines

*** Settings ***
Documentation    Test RAS sanity scenarios.

Resource        ../../lib/openbmc_ffdc.robot
Resource        ../../lib/openbmc_ffdc_utils.robot
Resource        ../../lib/openbmc_ffdc_methods.robot
Resource        ../../lib/ras/host_utils.robot
Resource        ../../openpower/ras/ras_utils.robot
Library         ../../lib/utils.py
Variables       ../../lib/ras/variables.py
Variables       ../../data/variables.py

Suite Setup      Redfish Power On
Test Setup       Printn
Test Teardown    FFDC On Test Case Fail

*** Variables ***
${proc_chip_id}    0

# mention count to read system memory.
${count}           128

*** Test Cases ***

Test BMC Getscom
    [Documentation]  Do getscom operation.
    [Tags]  Test_BMC_Getscom
    ${value}=  Get From Dictionary  ${ERROR_INJECT_DICT}  MCACALIFIR_RECV1
    Pdbg  -p${proc_chip_id} getscom 0x${value[0]}

Test BMC Getcfam
    [Documentation]  Do getcfam operation.
    [Tags]  Test_BMC_Getcfam
    Pdbg  -p${proc_chip_id} getcfam 0x${cfam_address}

Test BMC Getmem
    [Documentation]  Do getmem operation.
    [Tags]  Test_BMC_Getmem
    Pdbg  -p${proc_chip_id} getmem 0x${mem_address} ${count}


*** Settings ***

Resource        tests/NPSP.robot
Suite Setup     Open Test Browser
Suite Teardown  Delete Records and Close Browser

*** Variables ***
${task3_1}  Follow-Up Phone Call3

*** Test Cases ***

Create Engagement Plan and Edit to Add New Task
    ${plan_name}     ${task1_1}    ${sub_task1_1}     ${task2_1}     Create Engagement Plan
    Unselect Frame
    Select App Launcher Tab  Engagement Plan Templates
    Click Link    link=${plan_name}
    Click Link    link=Show more actions
    Click Link    link=Edit
    #Sleep    2
    Select Frame With Title    Manage Engagement Plan Template
    Page Scroll To Locator    button    Add Task
    Click Button With Value    Add Task
    Enter Task Id and Subject    Task 3    ${task3_1}
    Page Scroll To Locator    button    Save
    Click Button With Value    Save
    Unselect Frame
    Verify Engagement Plan    ${plan_name}    ${task1_1}    ${sub_task1_1}     ${task2_1}    ${task3_1}

Tag unstable robot test

*** Settings ***

Resource        tests/NPSP.robot
Suite Setup     Open Test Browser
Suite Teardown  Delete Records and Close Browser

*** Variables ***
${task3_1}  Follow-Up Phone Call3

*** Test Cases ***

Create Engagement Plan and Edit to Add New Task
    [tags]  unstable
    ${plan_name}     ${task1_1}    ${sub_task1_1}     ${task2_1}     Create Engagement Plan
    Unselect Frame
    Select App Launcher Tab  Engagement Plan Templates
    Click Link    link=${plan_name}
    Click Link    link=Show more actions
    Click Link    link=Edit
    #Sleep    2
    Select Frame With Title    Manage Engagement Plan Template
    Page Scroll To Locator    button    Add Task
    Click Button With Value    Add Task
    Enter Task Id and Subject    Task 3    ${task3_1}
    Page Scroll To Locator    button    Save
    Click Button With Value    Save
    Unselect Frame
    Verify Engagement Plan    ${plan_name}    ${task1_1}    ${sub_task1_1}     ${task2_1}    ${task3_1}


*** Variables ***
${NeutronNorthbound}    /controller/nb/v2/neutron
${NetworkNorthbound}    ${NeutronNorthbound}/networks
${SubnetNorthbound}     ${NeutronNorthbound}/subnets
${PortNorthbound}       ${NeutronNorthbound}/ports

*** Settings ***
Suite Setup       Create Session    ODL    http://${CONTROLLER}:${PORT}    headers=${HEADERS}    auth=${AUTH}
Suite Teardown    Delete All Sessions
Library           RequestsLibrary
Variables         ../../../variables/Variables.py

*** Test Cases ***
Get the complete list of networks
    [Tags]    reachability
    ${resp}   get request    ODL    ${NetworkNorthbound}
    Should be Equal As Strings    ${resp.status_code}    200

Get the complete list of subnets
    [Tags]    reachability
    ${resp}   get request    ODL    ${SubnetNorthbound}
    Should be Equal As Strings    ${resp.status_code}    200

Get the complete list of ports
    [Tags]    reachability
    ${resp}   get request    ODL    ${PortNorthbound}
    Should be Equal As Strings    ${resp.status_code}    200

Add documentation to conform to odlreport2db.py

*** Variables ***
${NeutronNorthbound}    /controller/nb/v2/neutron
${NetworkNorthbound}    ${NeutronNorthbound}/networks
${SubnetNorthbound}     ${NeutronNorthbound}/subnets
${PortNorthbound}       ${NeutronNorthbound}/ports

*** Settings ***
Suite Setup       Create Session    ODL    http://${CONTROLLER}:${PORT}    headers=${HEADERS}    auth=${AUTH}
Suite Teardown    Delete All Sessions
Library           RequestsLibrary
Variables         ../../../variables/Variables.py

*** Test Cases ***
Get the complete list of networks
    [Documentation]    Get the complete list of networks
    [Tags]    reachability
    ${resp}   get request    ODL    ${NetworkNorthbound}
    Should be Equal As Strings    ${resp.status_code}    200

Get the complete list of subnets
    [Documentation]    Get the complete list of subnets
    [Tags]    reachability
    ${resp}   get request    ODL    ${SubnetNorthbound}
    Should be Equal As Strings    ${resp.status_code}    200

Get the complete list of ports
    [Documentation]    Get the complete list of ports
    [Tags]    reachability
    ${resp}   get request    ODL    ${PortNorthbound}
    Should be Equal As Strings    ${resp.status_code}    200


# Copyright Project Harbor Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#	http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License

*** Settings ***
Documentation  Harbor BATs
Resource  ../../resources/Util.robot
Default Tags  Nightly

*** Variables ***
${HARBOR_URL}  https://${ip}
${HARBOR_ADMIN}  admin

*** Test Cases ***
Test Case - Main Menu Routing
    [Tags]  main_menu_routing
    Init Chrome Driver
    Sign In Harbor  ${HARBOR_URL}  ${HARBOR_ADMIN}  ${HARBOR_PASSWORD}
    &{routing}=	 Create Dictionary  harbor/projects=//projects//div//h2[contains(.,'Projects')]
    ...  harbor/logs=//hbr-log//div//h2[contains(.,'Logs')]
    ...  harbor/users=//harbor-user//div//h2[contains(.,'Users')]
    ...  harbor/robot-accounts=//system-robot-accounts//h2[contains(.,'Robot Accounts')]
    ...  harbor/registries=//hbr-endpoint//h2[contains(.,'Registries')]
    ...  harbor/replications=//total-replication//h2[contains(.,'Replications')]
    ...  harbor/distribution/instances=//dist-instances//div//h2[contains(.,'Instances')]
    ...  harbor/labels=//app-labels//h2[contains(.,'Labels')]
    ...  harbor/project-quotas=//app-project-quotas//h2[contains(.,'Project Quotas')]
    ...  harbor/interrogation-services/scanners=//config-scanner//div//h4[contains(.,'Image Scanners')]
    ...  harbor/interrogation-services/vulnerability=//vulnerability-config//div//button[contains(.,'SCAN NOW')]
    ...  harbor/gc=//app-gc-page//h2[contains(.,'Garbage Collection')]
    ...  harbor/configs/auth=//config//config-auth//label[contains(.,'Auth Mode')]
    ...  /harbor/configs/email=//config//config-email//label[contains(.,'Email Server Port')]
    ...  harbor/configs/setting=//config//system-settings//label[contains(.,'Project Creation')]
    FOR  ${key}  IN  @{routing.keys()}
        Retry Double Keywords When Error  Go To  ${HARBOR_URL}/${key}  Retry Wait Element  ${routing['${key}']}
    END


# Copyright 2018 Nathan Sommer and Ben Coleman
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

*** Settings ***
Resource    resources/setup.robot
Test Setup    Setup Server and Client Accounts
Force Tags    gkeep_modify

*** Keywords ***

Setup Server and Client Accounts
    Launch Gkeepd And Configure Admin Account on Client
    Add Faculty and Configure Accounts on Client    faculty1
    Establish Course    faculty1    cs1   student1    student2
    Add Assignment to Client  faculty1  good_simple
    Gkeep Upload Succeeds   faculty1   cs1    good_simple
    Gkeep Publish Succeeds   faculty1   cs1    good_simple

*** Test Cases ***

Trigger Runs On New Assignment
    Gkeep Trigger Succeeds   faculty1   cs1    good_simple


#lang racket/base
(require "../utils/utils.rkt")
(require (rep type-rep))

(provide (all-defined-out))

(define current-seen (make-parameter null))
(define (currently-subtyping?) (not (null? (current-seen))))

(define (seen-before s t) (cons (Type-seq s) (Type-seq t)))
(define (remember s t A) (cons (seen-before s t) A))
(define (seen? s t) (member (seen-before s t) (current-seen)))

Add contract for seen parameter.

#lang racket/base
(require "../utils/utils.rkt")
(require (rep type-rep) (contract-req))

(provide (except-out (all-defined-out) current-seen))
(provide/cond-contract [current-seen (parameter/c list?)])

(define current-seen (make-parameter null))
(define (currently-subtyping?) (not (null? (current-seen))))

(define (seen-before s t) (cons (Type-seq s) (Type-seq t)))
(define (remember s t A) (cons (seen-before s t) A))
(define (seen? s t) (member (seen-before s t) (current-seen)))


#lang racket/base

(require rackunit
         "../../rastache.rkt"
         (for-syntax racket/base))

(provide (all-defined-out))

; Rastache test case
(define-syntax (rast-t-case stx)
  (syntax-case stx ()
    [(_ t-name hash t-template t-expected t-error-msg)
     #'(test-case
        t-name
        (let ([rendered (open-output-string)]
              [tokens (rastache-compile/open-string t-template)]
              [expected t-expected])
          (rastache-render tokens hash rendered)
          (check-equal? (get-output-string rendered)
                        expected
                        t-error-msg)))]))

Fix error in call of rastach implementation for tests

#lang racket/base

(require rackunit
         "../rastache.rkt"
         (for-syntax racket/base))

(provide (all-defined-out))

; Rastache test case
(define-syntax (rast-t-case stx)
  (syntax-case stx ()
    [(_ t-name hash t-template t-expected t-error-msg)
     #'(test-case
        t-name
        (let ([rendered (open-output-string)]
              [tokens (rastache-compile/open-string t-template)]
              [expected t-expected])
          (rastache-render tokens hash rendered)
          (check-equal? (get-output-string rendered)
                        expected
                        t-error-msg)))]))


#lang racket/base
(require rackunit/docs-complete)
;; these are currently undocumented in `racket' as well
(define exclude '(define-place
                  deserialize-info:set-v0
                  make-primitive-class
                  place-sleep
                  procedure-closure-contents-eq?
                  processor-count))
(check-docs (quote typed-scheme) #:skip exclude)
(check-docs (quote typed/scheme) #:skip exclude)
(check-docs (quote typed/scheme/base) #:skip exclude)
(check-docs (quote typed/racket) #:skip exclude)
(check-docs (quote typed/racket/base) #:skip exclude)

Update excluded docs for TR.

#lang racket/base
(require rackunit/docs-complete)
;; these are currently undocumented in `racket' as well
(define exclude '(make-primitive-class
                  make-custom-set
                  make-mutable-custom-set
                  make-weak-custom-set
                  place-sleep))
(check-docs (quote typed-scheme) #:skip exclude)
(check-docs (quote typed/scheme) #:skip exclude)
(check-docs (quote typed/scheme/base) #:skip exclude)
(check-docs (quote typed/racket) #:skip exclude)
(check-docs (quote typed/racket/base) #:skip exclude)


#lang typed/racket
(require racket/syntax)

(: f : -> Syntax)
(define (f)
  (with-syntax* ([(x ...) (list 1 2 3)])
    #`(#,(syntax +) x ...)))

Fix test case for last commit.

#lang typed/racket
(require racket/syntax)

(: f : -> (Syntaxof Any))
(define (f)
  (with-syntax* ([(x ...) (list 1 2 3)])
    #`(#,(syntax +) x ...)))


#lang s-exp "minimal.rkt"

(providing (libs (except scheme/base #%module-begin #%top-interaction with-handlers lambda #%app for for*)
                 (except "base-env/prims.rkt")
                 (except "base-env/base-types.rkt")
                 (except "base-env/base-types-extra.rkt"))
	   (basics #%module-begin
		   #%top-interaction
		   lambda
		   #%app))
(require "base-env/extra-procs.rkt"
         (for-syntax "base-env/base-types-extra.rkt"))
(provide (rename-out [with-handlers: with-handlers])
         (for-syntax (all-from-out "base-env/base-types-extra.rkt"))
	 assert defined? with-type for for*)

Fix requires/provides of `typed-scheme' language.

#lang s-exp "minimal.rkt"

(providing (libs (except scheme/base #%module-begin #%top-interaction with-handlers lambda #%app for for*))
	   (basics #%module-begin #%top-interaction lambda #%app))
(require typed-scheme/base-env/extra-procs
         typed-scheme/base-env/prims
         typed-scheme/base-env/base-types
         typed-scheme/base-env/base-types-extra
	 (for-syntax typed-scheme/base-env/base-types-extra))
(provide (rename-out [with-handlers: with-handlers]
                     [define-type-alias define-type])
         (except-out (all-from-out typed-scheme/base-env/prims)
                     with-handlers: for/annotation for*/annotation)
         (all-from-out typed-scheme/base-env/base-types)
         (all-from-out typed-scheme/base-env/base-types-extra)
	 assert defined? with-type for for*
         (for-syntax (all-from-out typed-scheme/base-env/base-types-extra)))


#;
(exn-pred exn:fail:contract?)
#lang racket

(module typed typed/racket
  (: d Any)
  (define d (delay (lambda: ([x : Integer]) (+ x 1))))
  (provide d))

(require 'typed)

;; this line should raise a ctc error
((force d) 6)

Test the error message instead of a predicate

#;
(exn-pred #rx"Attempted to use a higher-order value passed as `Any`")
#lang racket

(module typed typed/racket
  (: d Any)
  (define d (delay (lambda: ([x : Integer]) (+ x 1))))
  (provide d))

(require 'typed)

;; this line should raise a ctc error
((force d) 6)


#lang racket/base

(provide (all-defined-out))

(struct contract-profile
  (total-time n-samples n-contract-samples
   ;; (pairof blame? profile-sample)
   ;; samples taken while a contract was running
   live-contract-samples
   ;; (listof blame?)
   ;; all the blames that were observed during sampling
   all-blames
   ;; profile?
   ;; regular time profile
   regular-profile))

(define (samples-time samples)
  (for/sum ([s (in-list samples)])
    (cadr s)))

(define output-file-prefix "tmp-contract-profile-")

;; for testing. don't generate output files
(define dry-run? (make-parameter #f))

(define-syntax-rule (with-output-to-report-file file body ...)
  (unless (dry-run?)
    (with-output-to-file file
      #:exists 'replace
      (lambda () body ...))))

Fix contract profiler tests to test more.

#lang racket/base

(require racket/port)

(provide (all-defined-out))

(struct contract-profile
  (total-time n-samples n-contract-samples
   ;; (pairof blame? profile-sample)
   ;; samples taken while a contract was running
   live-contract-samples
   ;; (listof blame?)
   ;; all the blames that were observed during sampling
   all-blames
   ;; profile?
   ;; regular time profile
   regular-profile))

(define (samples-time samples)
  (for/sum ([s (in-list samples)])
    (cadr s)))

(define output-file-prefix "tmp-contract-profile-")

;; for testing. don't generate output files
(define dry-run? (make-parameter #f))

(define-syntax-rule (with-output-to-report-file file body ...)
  (if (dry-run?)
      (parameterize ([current-output-port (open-output-nowhere)])
        body ...)
      (with-output-to-file file
        #:exists 'replace
        (lambda () body ...))))


(("planet2-example" "https://github.com/jeapostrophe/planet2-example/")
 #;("games" "git://github.com/racket/games/"))

Fix URL for test pkg.

(("planet2-example" "git://github.com/jeapostrophe/planet2-example/")
 #;("games" "git://github.com/racket/games/"))


#lang racket/load
(module a racket
  (define memory%
    (class object%
      (super-new)
      (define/public (malloc) 1)
      (define/public (free n) (void))))

  (provide/contract
   [memory%
    (class/c [malloc (->m number?)]
             [free (->m number? void)])]))

(module b racket
  (require 'a tests/eli-tester)

  (define memory (new memory%))

  (define a (send memory malloc))
  (test
   (send memory free a)
   (send memory free "foo") =error> #rx"expected \\<number"
   (send memory free a)))

(require 'b)

Test is sensitive to contract messages

#lang racket/load
(module a racket
  (define memory%
    (class object%
      (super-new)
      (define/public (malloc) 1)
      (define/public (free n) (void))))

  (provide/contract
   [memory%
    (class/c [malloc (->m number?)]
             [free (->m number? void)])]))

(module b racket
  (require 'a tests/eli-tester)

  (define memory (new memory%))

  (define a (send memory malloc))
  (test
   (send memory free a)
   (send memory free "foo") =error> #rx"expected: number\\?"
   (send memory free a)))

(require 'b)


#;
(
with-type.rkt line 13 col 19 - + - binary float
34.6
)

#lang racket

(require typed/racket)

(with-type ([fun (Float -> Float)]
            [val Float])
  (define (fun x) (+ x val))
  (define val 17.3))

(fun val)

Fix test log to use new format.

#;
(
with-type.rkt 13:19 + -- binary float
34.6
)

#lang racket

(require typed/racket)

(with-type ([fun (Float -> Float)]
            [val Float])
  (define (fun x) (+ x val))
  (define val 17.3))

(fun val)


#;
(exn-pred exn:fail:contract? #rx".*contract violation.*contract.*f.*\\(-> Number Number\\).*")

#lang scheme/load

(module m typed/scheme
  (: f (Number -> Number))
  (define (f x) (add1 x))
  (define g 17)
  (provide f g))

(module violator scheme
  (require 'm)
  (f 'foo))

(module o typed/scheme
  (require 'violator))

(require 'o)

Fix TR test for new contract error message format.

#;
(exn-pred exn:fail:contract? #rx".*contract violation.*\\(-> Number Number\\).*contract.*f.*")

#lang scheme/load

(module m typed/scheme
  (: f (Number -> Number))
  (define (f x) (add1 x))
  (define g 17)
  (provide f g))

(module violator scheme
  (require 'm)
  (f 'foo))

(module o typed/scheme
  (require 'violator))

(require 'o)


#lang racket/base
(require rackunit/docs-complete)
;(check-docs (quote deinprogramm/world))
;(check-docs (quote deinprogramm/turtle))
;(check-docs (quote deinprogramm/test-suite))
;(check-docs (quote deinprogramm/syntax-checkers))
;(check-docs (quote deinprogramm/run-dmda-code))
;(check-docs (quote deinprogramm/line3d))
;(check-docs (quote deinprogramm/image))
;(check-docs (quote deinprogramm/DMdA))
;(check-docs (quote deinprogramm/DMdA-vanilla-reader))
;(check-docs (quote deinprogramm/DMdA-reader))
;(check-docs (quote deinprogramm/DMdA-beginner-reader))
;(check-docs (quote deinprogramm/DMdA-assignments-reader))
;(check-docs (quote deinprogramm/DMdA-advanced-reader))
;(check-docs (quote deinprogramm/define-record-procedures))
;(check-docs (quote deinprogramm/convert-explicit))

(check-docs (quote deinprogramm/DMdA-beginner) #:skip #rx"^#%")
(check-docs (quote deinprogramm/DMdA-vanilla) #:skip #rx"^#%")
(check-docs (quote deinprogramm/DMdA-advanced) #:skip #rx"^#%")
(check-docs (quote deinprogramm/DMdA-assignments) #:skip #rx"^#%")

Add DMdA teachpacks to documentation check.

#lang racket/base
(require rackunit/docs-complete)

(check-docs (quote deinprogramm/world))
(check-docs (quote deinprogramm/image))

(check-docs (quote deinprogramm/DMdA-beginner) #:skip #rx"(^#%)|(^\\.\\.)|(^contract$)|(^define-contract$)")
(check-docs (quote deinprogramm/DMdA-vanilla) #:skip #rx"(^#%)|(^\\.\\.)|(^contract$)|(^define-contract$)")
(check-docs (quote deinprogramm/DMdA-advanced) #:skip #rx"(^#%)|(^\\.\\.)|(^contract$)|(^define-contract$)")
(check-docs (quote deinprogramm/DMdA-assignments) #:skip #rx"(^#%)|(^\\.\\.)|(^contract$)|(^define-contract$)")


#lang racket/base

(require "../utils/utils.rkt"
         (rep type-rep)
         (prefix-in c: (contract-req))
         (types subtype)
         racket/match
         racket/list)

(provide/cond-contract
 [Un (() #:rest (c:listof Type/c) . c:->* . Type/c)])

;; List[Type] -> Type
;; Argument types should not overlap or be union types
(define (make-union* types)
  (match types
    [(list t) t]
    [_ (make-Union types)]))

;; a is a Type (not a union type)
;; b is a List[Type] (non overlapping, non Union-types)
;; The output is a non overlapping list of non Union types.
(define (merge a b)
  (define b* (make-union* b))
  (cond
    [(subtype a b*) b]
    [(subtype b* a) (list a)]
    [else (cons a b)]))

;; Type -> List[Type]
(define (flat t)
  (match t
    [(Union: es) es]
    [_ (list t)]))

;; Union constructor
;; Normalizes representation by sorting types.
;; Type * -> Type
;; The input types can overlap and be union types
(define (Un . args)
  (make-union* (foldr merge '() (remove-dups (sort (append-map flat args) type<?)))))

Add back some special cases.

#lang racket/base

(require "../utils/utils.rkt"
         (rep type-rep)
         (prefix-in c: (contract-req))
         (types subtype)
         racket/match
         racket/list)

(provide/cond-contract
 [Un (() #:rest (c:listof Type/c) . c:->* . Type/c)])

;; List[Type] -> Type
;; Argument types should not overlap or be union types
(define (make-union* types)
  (match types
    [(list t) t]
    [_ (make-Union types)]))

;; a is a Type (not a union type)
;; b is a List[Type] (non overlapping, non Union-types)
;; The output is a non overlapping list of non Union types.
(define (merge a b)
  (define b* (make-union* b))
  (cond
    [(subtype a b*) b]
    [(subtype b* a) (list a)]
    [else (cons a b)]))

;; Type -> List[Type]
(define (flat t)
  (match t
    [(Union: es) es]
    [_ (list t)]))

(define empty-union (make-Union null))

;; Union constructor
;; Normalizes representation by sorting types.
;; Type * -> Type
;; The input types can overlap and be union types
(define Un
  (case-lambda
    [() empty-union]
    [(t) t]
    [args
     (define ts (foldr merge '()
                       (remove-dups (sort (append-map flat args) type<?))))
     (make-union* ts)]))


; From Harley Montgomery, a MCMC transition probability for a Dirichlet Mixture Model

(herbie-test ((c_p (positive default)) (c_n (positive default)) t s)
  "Harley's example"
  (/ (* (expt (/ (+ 1 (exp (- s)))) e+) (expt (- 1 (/ (+ 1 (exp (- s))))) e-))
     (* (expt (/ (+ 1 (exp (- t)))) e+) (expt (- 1 (/ (+ 1 (exp (- t))))) e-)))
  (* (expt (/ (+ 1 (exp (- t))) (+ 1 (exp (- s)))) e+)
     (expt (/ (+ 1 (exp t)) (+ 1 (exp s))) e-)))

Fix variable names in Harley's example

; From Harley Montgomery, a MCMC transition probability for a Dirichlet Mixture Model

(lambda ([c_p (positive default)] [c_n (positive default)] t s)
  #:name "Harley's example"
  (/ (* (expt (/ (+ 1 (exp (- s)))) c_p) (expt (- 1 (/ (+ 1 (exp (- s))))) c_n))
     (* (expt (/ (+ 1 (exp (- t)))) c_p) (expt (- 1 (/ (+ 1 (exp (- t))))) c_n)))
  #:target
  (* (expt (/ (+ 1 (exp (- t))) (+ 1 (exp (- s)))) c_p)
     (expt (/ (+ 1 (exp t)) (+ 1 (exp s))) c_n)))


#;
(
 real-in-float-expr.rkt 12:0 (#%app * (quote 3) (quote 2.3)) -- binary, args all float-arg-expr, return type not Float -- caused by: 10:8 (quote 3)
 real-in-float-expr.rkt 18:0 (#%app * (quote 2) (quote 2.0)) -- binary, args all float-arg-expr, return type not Float -- caused by: 17:8 (quote 2)
 6.8999999999999995
 6
 5
 4.0
 )
#lang typed/racket

(* (ann 3 Real) ; with type Real, typechecker must assume it could be exact 0
   2.3)

(* (ann 2 Integer) (ann 3 Integer)) ; but these have nothing to do with floats, should not be logged
(+ (ann 2 Integer) (ann 3 Integer))

(* (ann 2 Natural) 2.0) ; close calls that result in Nonnegative-Real and co (i.e. not directly Real) should be reported too

Add extra checks to avoid spurious close call reporting involving integer operations.

#;
(
 real-in-float-expr.rkt 14:0 (#%app * (quote 3) (quote 2.3)) -- binary, args all float-arg-expr, return type not Float -- caused by: 14:8 (quote 3)
 real-in-float-expr.rkt 22:0 (#%app * (quote 2) (quote 2.0)) -- binary, args all float-arg-expr, return type not Float -- caused by: 22:8 (quote 2)
 6.8999999999999995
 6
 5
 6
 5
 4.0
 )
#lang typed/racket

(* (ann 3 Real) ; with type Real, typechecker must assume it could be exact 0
   2.3)

(* (ann 2 Integer) (ann 3 Integer)) ; but these have nothing to do with floats, should not be logged
(+ (ann 2 Integer) (ann 3 Integer))
(* 2 3)
(+ 2 3)

(* (ann 2 Natural) 2.0) ; close calls that result in Nonnegative-Real and co (i.e. not directly Real) should be reported too


#lang racket/base

;; This file provides Typed Racket bindings for values that need
;; contract protection, even in typed code.

(require "../utils/utils.rkt"
         (env init-envs)
         (types abbrev union)
         (utils any-wrap)
         (only-in (rep type-rep)
                  make-Prompt-Tagof))

;; this submodule defines the contracted versions
(module contracted racket/base
  (require racket/contract
           (rename-in
            racket/base
            [default-continuation-prompt-tag -default-continuation-prompt-tag])
           "../utils/utils.rkt"
           (utils any-wrap))

  (provide default-continuation-prompt-tag)

  ;; default tag should use Any wrappers
  (define default-continuation-prompt-tag
    (contract (-> (prompt-tag/c any-wrap/c #:call/cc any-wrap/c))
              -default-continuation-prompt-tag
              'typed 'untyped)))

(require (for-template (submod "." contracted))
         (submod "." contracted))

(provide default-continuation-prompt-tag)

;; set up the type environment
(define-initial-env initialize-contracted
  [default-continuation-prompt-tag
    (-> (make-Prompt-Tagof ManyUniv (-> ManyUniv ManyUniv)))])

Fix blame parties for proxied default prompt tag

#lang racket/base

;; This file provides Typed Racket bindings for values that need
;; contract protection, even in typed code.

(require "../utils/utils.rkt"
         (env init-envs)
         (types abbrev union)
         (utils any-wrap)
         (only-in (rep type-rep)
                  make-Prompt-Tagof))

;; this submodule defines the contracted versions
(module contracted racket/base
  (require racket/contract
           (rename-in
            racket/base
            [default-continuation-prompt-tag -default-continuation-prompt-tag])
           "../utils/utils.rkt"
           (utils any-wrap))

  (provide default-continuation-prompt-tag)

  ;; default tag should use Any wrappers
  (define default-continuation-prompt-tag
    (contract (-> (prompt-tag/c any-wrap/c #:call/cc any-wrap/c))
              -default-continuation-prompt-tag
              ;; TODO: we actually want to be able to specify that the
              ;;       "contract from" party is not the untyped party
              ;;       here, but that's not currently possible
              'untyped 'typed)))

(require (for-template (submod "." contracted))
         (submod "." contracted))

(provide default-continuation-prompt-tag)

;; set up the type environment
(define-initial-env initialize-contracted
  [default-continuation-prompt-tag
    (-> (make-Prompt-Tagof ManyUniv (-> ManyUniv ManyUniv)))])


#lang racket/base

(module fish racket/base
  (require racket/class)
  (define fish%
    (class object%
      (init-field weight)
      (define/public (get-weight) weight)
      (define/public (inc-weight-by! x negate?)
        (set! weight (+ (if negate? (- weight) weight) x)))
      (super-new)))
  (provide fish%))

(module fish-client typed/racket/base
  (require racket/class)
  (require/typed (submod ".." fish) [fish% Fish%])

  (define-type-alias Fish% (Class () ([weight Real]) ([get-weight (-> Real)]
                                                      [inc-weight-by! (Real Boolean -> Void)])))

  (: f ((Instance Fish%) -> Real))
  (define (f b) (send b get-weight))

  (: g (Real -> (Instance Fish%)))
  (define (g w) (new fish% [weight w]))

  (: h ((Instance Fish%) -> Void))
  (define (h b) (send b inc-weight-by! 2 #f))

  (unless (= 0 (f (g 0))) (error 'send.rkt "expected 0"))
  (unless (= 3 (let ([b (g 1)])
                 (h b)
                 (f b)))
    (error 'send.rkt "expected 3")))

(require (submod "." fish-client))

Fix integration test for new class type syntax

#lang racket/base

(module fish racket/base
  (require racket/class)
  (define fish%
    (class object%
      (init-field weight)
      (define/public (get-weight) weight)
      (define/public (inc-weight-by! x negate?)
        (set! weight (+ (if negate? (- weight) weight) x)))
      (super-new)))
  (provide fish%))

(module fish-client typed/racket/base
  (require racket/class)
  (require/typed (submod ".." fish) [fish% Fish%])

  (define-type-alias Fish% (Class (init [weight Real])
                                  [get-weight (-> Real)]
                                  [inc-weight-by! (Real Boolean -> Void)]))

  (: f ((Instance Fish%) -> Real))
  (define (f b) (send b get-weight))

  (: g (Real -> (Instance Fish%)))
  (define (g w) (new fish% [weight w]))

  (: h ((Instance Fish%) -> Void))
  (define (h b) (send b inc-weight-by! 2 #f))

  (unless (= 0 (f (g 0))) (error 'send.rkt "expected 0"))
  (unless (= 3 (let ([b (g 1)])
                 (h b)
                 (f b)))
    (error 'send.rkt "expected 3")))

(require (submod "." fish-client))


#lang racket/base
(provide assert defined?)

(define-syntax assert
  (syntax-rules ()
    ((assert v)
     (or v (error "Assertion failed")))
    ((assert v pred)
     (let ((val v))
       (if (pred val) val (error "Assertion failed"))))))

(define (defined? v)
  (not (equal? v (letrec ([x x]) x))))

Improve TR assertion error message

#lang racket/base
(provide assert defined?)

(define-syntax assert
  (syntax-rules ()
    ((assert v)
     (or v (error (format "Assertion failed on ~v" v))))
    ((assert v pred)
     (let ((val v))
       (if (pred val)
           val
           (error (format "Assertion ~a failed on ~v" pred val)))))))

(define (defined? v)
  (not (equal? v (letrec ([x x]) x))))


#lang info

(define scribblings '(["scribblings/collections.scrbl" (multi-page) ("Data Libraries")]))

(define cover-omit-paths
  '("scribblings"))

Revert "Move docs into the "Data Libraries" category"

#lang info

(define scribblings '(["scribblings/collections.scrbl" (multi-page)]))

(define cover-omit-paths
  '("scribblings"))


#lang meta/web

(require "resources.rkt" "data.rkt" "../www/download.rkt")

(define (in-ftp . paths)
  (string-join (cons "/var/ftp/pub/racket" paths) "/"))

(define docs       (symlink (in-ftp "docs")))
(define installers (symlink (in-ftp "installers")))
(define stubs      (symlink "/www/stubs"))

(provide index)
(define index
  @page[#:link-title "Downloads" #:part-of 'download]{
    @div[style: "float: right;"]{@download-button}
    Use these links to browse the download directories directly:
    @ul{@li{Current @a[href: `(,installers "/recent")]{installers}
            (or @a[href: installers]{all versions}).}
        @li{Current documentation in
            @a[href: `(,docs "/recent/html")]{HTML} and in
            @a[href: `(,docs "/recent/pdf")]{PDF}
            (or @a[href: docs]{all versions}).}}})

Add symlink and html link to the libs content

#lang meta/web

(require "resources.rkt" "data.rkt" "../www/download.rkt")

(define (in-ftp . paths)
  (string-join (cons "/var/ftp/pub/racket" paths) "/"))

(define docs       (symlink (in-ftp "docs")))
(define installers (symlink (in-ftp "installers")))
(define libs       (symlink (in-ftp "libs")))
(define stubs      (symlink "/www/stubs"))

(provide index)
(define index
  @page[#:link-title "Downloads" #:part-of 'download]{
    @div[style: "float: right;"]{@download-button}
    Use these links to browse the download directories directly:
    @ul{@li{Current @a[href: `(,installers "/recent")]{installers}
            (or @a[href: installers]{all versions}).}
        @li{Current documentation in
            @a[href: `(,docs "/recent/html")]{HTML} and in
            @a[href: `(,docs "/recent/pdf")]{PDF}
            (or @a[href: docs]{all versions}).}
        @li{Binary @a[href: libs]{libraries} mainly for GRacket.}}})


#lang info

(define collection 'multi)

(define deps '("racket-test"
               "rackunit-test"
               "gui-test"
               "db-test"
               "htdp-test"
               "redex-test"
               "drracket-test"
               "profile-test"
               "srfi-test"
               "errortrace-test"
               "r6rs-test"
               "web-server-test"
               "typed-racket-test"
               "xrepl-test"
               "scribble-test"
               "unstable-test"
               "compiler-test"
               "compatibility-test"
               "data-test"
               "net-test"
               "planet-test"
               "syntax-color-test"
               "images-test"
               "plot-test"
               "math-test"
               "racket-benchmarks"))

(define pkg-desc "tests for \"main-distribution\"")

(define pkg-authors '(eli jay matthias mflatt robby))

Add HTML tests to main-distribution-test

#lang info

(define collection 'multi)

(define deps '("racket-test"
               "rackunit-test"
               "gui-test"
               "db-test"
               "htdp-test"
               "html-test"
               "redex-test"
               "drracket-test"
               "profile-test"
               "srfi-test"
               "errortrace-test"
               "r6rs-test"
               "web-server-test"
               "typed-racket-test"
               "xrepl-test"
               "scribble-test"
               "unstable-test"
               "compiler-test"
               "compatibility-test"
               "data-test"
               "net-test"
               "planet-test"
               "syntax-color-test"
               "images-test"
               "plot-test"
               "math-test"
               "racket-benchmarks"))

(define pkg-desc "tests for \"main-distribution\"")

(define pkg-authors '(eli jay matthias mflatt robby))


#lang info

(define collection "honu")
(define deps '("macro-debugger"
               "base"
               "parser-tools-lib"
               "rackunit-lib"))
(define build-deps '("scribble-lib"))

Move honu.vim to lib directory on install.

#lang info

(define collection "honu")
(define deps '("macro-debugger"
               "base"
               "parser-tools-lib"
               "rackunit-lib"))
(define build-deps '("scribble-lib"))

;; Make honu.vim easier to find by copying it to the "lib" directory:
(define copy-foreign-libs '("contrib/honu.vim"))


#;
(exn-pred exn:fail:contract? #rx".*contract violation.*blaming 'U.*")
#lang scheme/load

(module T typed-scheme

  (define-struct: [a] thing ([get : a]))

  (: thing->string ((thing String) -> String))
  (define (thing->string x)
    (string-append "foo" (thing-get x)))

  (provide (all-defined-out)))

(module U scheme

  (require 'T)

  (thing->string (make-thing 5)))

(require 'U)

Fix test for new contract error message format.

#;
(exn-pred exn:fail:contract? #rx".*contract violation.*blaming U.*")
#lang scheme/load

(module T typed-scheme

  (define-struct: [a] thing ([get : a]))

  (: thing->string ((thing String) -> String))
  (define (thing->string x)
    (string-append "foo" (thing-get x)))

  (provide (all-defined-out)))

(module U scheme

  (require 'T)

  (thing->string (make-thing 5)))

(require 'U)


#lang info

(define collection 'multi)

(define name "alexis-collections")
(define version "0.2.0")

(define deps
  '("base"
    "rackunit-lib"
    "alexis-util"))
(define build-deps
  '("scribble-lib"
    "racket-doc"
    "cover"))

Add cover-coveralls to the build dependencies

#lang info

(define collection 'multi)

(define name "alexis-collections")
(define version "0.2.0")

(define deps
  '("alexis-util"
    "base"
    "rackunit-lib"))
(define build-deps
  '("cover"
    "cover-coveralls"
    "racket-doc"
    "scribble-lib"))


#lang racket
(require casio/test)

; Some tests on Casio's ability to reassociate and cancel
(casio-test (x y)
  "Canceling after commutation"
  (- (+ x y) (+ y x))
  0)

(casio-test (x)
  "Canceling after reassociation"
  (- (+ 1 x) x)
  1)

(casio-test (x)
  "Canceling after reassociation and commutation"
  (- (+ x 1) x)
  1)

(casio-test (x y z)
  "Canceling after commutation and reassociation"
  (- (+ (+ x y) z) (+ x (+ y z)))
  0)

(casio-test (a)
  "Reducing (a+1)^2 - 1"
  (- (square (+ a 1)) 1)
  (* a (+ a 2)))

(casio-test (a b)
  "Reducing a^2 - b^2"
  (- (square a) (square b))
  (* (+ a b) (- a b)))

Change square to sqr in tests

#lang racket
(require casio/test)

; Some tests on Casio's ability to reassociate and cancel
(casio-test (x y)
  "Canceling after commutation"
  (- (+ x y) (+ y x))
  0)

(casio-test (x)
  "Canceling after reassociation"
  (- (+ 1 x) x)
  1)

(casio-test (x)
  "Canceling after reassociation and commutation"
  (- (+ x 1) x)
  1)

(casio-test (x y z)
  "Canceling after commutation and reassociation"
  (- (+ (+ x y) z) (+ x (+ y z)))
  0)

(casio-test (a)
  "Reducing (a+1)^2 - 1"
  (- (sqr (+ a 1)) 1)
  (* a (+ a 2)))

(casio-test (a b)
  "Reducing a^2 - b^2"
  (- (sqr a) (sqr b))
  (* (+ a b) (- a b)))


#lang info

(define scribblings '(["scribblings/collections.scrbl" (multi-page)]))

(define cover-omit-paths
  '("scribblings"))

Move docs into the "Data Libraries" category

#lang info

(define scribblings '(["scribblings/collections.scrbl" (multi-page) ("Data Libraries")]))

(define cover-omit-paths
  '("scribblings"))


(load-relative "loadtest.rktl")

(load-in-sandbox "beginner.ss")
(load-in-sandbox "beginner-abbr.ss")
(load-in-sandbox "intermediate.ss")
(load-in-sandbox "intermediate-lambda.ss")
(load-in-sandbox "advanced.ss")

(report-errs)

Fix file names for loading.

(load-relative "loadtest.rktl")

(load-in-sandbox "beginner.rktl")
(load-in-sandbox "beginner-abbr.rktl")
(load-in-sandbox "intermediate.rktl")
(load-in-sandbox "intermediate-lambda.rktl")
(load-in-sandbox "advanced.rktl")

(report-errs)


#lang racket/base

#|
   Copyright 2016-2017 Leif Andersen

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
|#

(require rackunit
         "test-utils.rkt"
         (prefix-in d: "../private/devices.rkt")
         "../devices.rkt")

(check-true (input-devices? (d:mk-input-devices)))

(let ()
  (define devices (list-input-devices))
  (check-true (input-devices? devices))
  (cameras devices)
  (video-devices devices)
  (audio-devices devices)
  (void))

Comment out one device test.

#lang racket/base

#|
   Copyright 2016-2017 Leif Andersen

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
|#

(require rackunit
         "test-utils.rkt"
         (prefix-in d: "../private/devices.rkt")
         "../devices.rkt")

(check-true (input-devices? (d:mk-input-devices)))

#|
(let ()
  (define devices (list-input-devices))
  (check-true (input-devices? devices))
  (cameras devices)
  (video-devices devices)
  (audio-devices devices)
  (void))
|#


#lang racket
(require casio/test)

; All code examples from mathjs
; https://github.com/josdejong/mathjs/blob/master/
; from files in
; /lib/function/probability/

(casio-bench (u1 u2)
  "normal distribution"
  (+ (* (* (/ 1 6) (expt (* -2 (log u1)) 0.5)) (cos (* (* 2 pi) u2))) 0.5))

Fix a test which referenced `pi`

#lang racket
(require casio/test)

; All code examples from mathjs
; https://github.com/josdejong/mathjs/blob/master/
; from files in
; /lib/function/probability/

(casio-bench (u1 u2)
  "normal distribution"
  (+ (* (* (/ 1 6) (expt (* -2 (log u1)) 0.5))
        (cos (* (* 2 3.141592653589793) u2))) 0.5))


#lang info

(define test-responsibles '((all (asumu stamourv cce))))

Add test props for racket/generic tests

#lang info

(define test-responsibles '((all (asumu stamourv cce))))

(define test-timeouts
  '(("benchmark.rkt" 300)))

(define test-randoms
  '("benchmark.rkt"))


#lang racket/base

(require rackunit rackunit/text-ui racket/runtime-path)

;; Runs all the files in the tests subdirectory.
;; A test fails if it throws an exception.

(define-runtime-path tests-dir "./tests")

(define tests
  (make-test-suite
   "syntax tests"
   (for/list ([t (in-directory tests-dir)])
     (test-suite
      (path->string t)
      (check-not-exn (lambda () (dynamic-require t #f)))))))

(run-tests tests)

Fix syntax test harness to work with compiled tests.

#lang racket/base

(require rackunit rackunit/text-ui racket/runtime-path)

;; Runs all the files in the tests subdirectory.
;; A test fails if it throws an exception.

(define-runtime-path tests-dir "./tests")

(define tests
  (make-test-suite
   "syntax tests"
   (for/list ([t (directory-list tests-dir)]
              #:when (regexp-match ".*rkt$" t))
     (test-suite
      (path->string t)
      (check-not-exn (lambda ()
                       (dynamic-require (build-path tests-dir t) #f)))))))

(run-tests tests)


#lang plai-typed
(define-type ArithC
    [numC (n : number)]
    [plusC (l : ArithC) (r : ArithC)]
    [multC (l : ArithC) (r : ArithC)])
(define (parse [s : s-expression]) : ArithC
    (cond
        [(s-exp-number? s) (numC (s-exp->number s))]
        [(s-exp-list? s)
            (let ([sl (s-exp->list s)])
                (case (s-exp->symbol (first sl))
                    [(+) (plusC (parse (second sl)) (parse (third sl)))]
                    [(*) (multC (parse (second sl)) (parse (third sl)))]
                    [else (error 'parse "INVALID LIST INPUT!")]))]
        [else (error 'parse "INVALID INPUT!")]))

Add some two new operations to the language

#lang plai-typed
;The data structure - The core language
(define-type ArithC
    [numC (n : number)]
    [plusC (l : ArithC) (r : ArithC)]
    [multC (l : ArithC) (r : ArithC)])
; New Data structure - The surface language
(define-type ArithS
    [numS (n : number)]
    [plusS (l : ArithS) (r : ArithS)]
    [subS (l : ArithS) (r : ArithS)]
    [multS (l : ArithS) (r : ArithS)]
    [uminuS (e : ArithS)])
;The parser itself - TODO: Change it to READ the expression, and use ArithS
(define (parse [s : s-expression]) : ArithC
    (cond
        [(s-exp-number? s) (numC (s-exp->number s))]
        [(s-exp-list? s)
            (let ([sl (s-exp->list s)])
                (case (s-exp->symbol (first sl))
                    [(+) (plusC (parse (second sl)) (parse (third sl)))]
                    [(*) (multC (parse (second sl)) (parse (third sl)))]
                    [else (error 'parse "INVALID LIST INPUT!")]))]
        [else (error 'parse "INVALID INPUT!")]))
;The interpreter
(define (interp [a : ArithC]) : number
    (type-case ArithC a
        [numC (n) n]
        [plusC (l r) (+ (interp l) (interp r))]
        [multC (l r) (* (interp l) (interp r))]))
;Desugar Function a - b =  a + (-1*b)
(define (desugar [as : ArithS]) : ArithC
    (type-case ArithS as
        [numS (n) (numC n)]
        [plusS (l r) (plusC (desugar l) (desugar r))]
        [multS (l r) (multC (desugar l) (desugar r))]
        [subS (l r) (plusC (desugar l) (multC (numC -1) (desugar r)))]
        [uminuS (e) (multC (numC -1) (desugar e)) ]))


#;
(exn-pred (regexp-quote "in: (for/flvector"))
#lang typed/racket/base

(require racket/flonum)
(module+ test
  (require typed/rackunit)
  (define (from upto)
    (for/flvector ([i (in-range from upto)])
      0.0)))

Add an explanation of the test case for PR 14389

#;
(exn-pred (regexp-quote "in: (for/flvector"))
#lang typed/racket/base

;; Test for PR 14389. Make sure that the reported source location
;; points to the expression, not the whole submodule contents.

(require racket/flonum)
(module+ test
  (require typed/rackunit)
  (define (from upto)
    (for/flvector ([i (in-range from upto)])
      0.0)))


#lang racket/base

(require rackunit
         "../rastache.rkt"
         (for-syntax racket/base))

(provide (all-defined-out))

; Rastache test case
(define-syntax (rast-t-case stx)
  (syntax-case stx ()
    [(_ t-name hash t-template t-expected t-error-msg)
     #'(test-case
        t-name
        (let ([rendered (open-output-string)]
              [tokens (rastache-compile/open-string t-template)]
              [expected t-expected])
          (rastache-render tokens hash rendered)
          (check-equal? (get-output-string rendered)
                        expected
                        t-error-msg)))]))

Add token-mock managment in tests

#lang racket/base

(require rackunit
         racket/format
         "../scanner.rkt"
         "../renderer.rkt"
         "../rastache.rkt"
         (for-syntax racket))

(provide (all-defined-out))

; Rastache test case
(define-syntax (rast-t-case stx)
  (syntax-case stx ()
    ;; rast-t-case: test-name context template expected fail-msg
    ;; expended to rackunit test case.
    [(_ t-name hash t-template t-expected t-error-msg)
     #'(test-case
        t-name
        (let ([rendered (open-output-string)]
              [tokens (rastache-compile/open-string t-template)]
              [expected t-expected])
          (rastache-render tokens hash rendered)
          (check-equal? (get-output-string rendered)
                        expected
                        t-error-msg)))]

    [(_ t-name hash t-template t-expected t-mock-token t-error-msg)
     (let ([make-name (λ (type syntax)
                         (format "~a -- ~a"
                                 type
                                 (syntax->datum syntax)))])
       (with-syntax
           ([scanner-t-name (make-name "SCANNER" #'t-name)]
            [scanner-t-error-msg (make-name "SCANNER" #'t-error-msg)]
            [render-t-name (make-name "RENDER" #'t-name)]
            [render-t-error-msg (make-name "RENDER" #'t-error-msg)])
         #'(begin
             (test-case
              scanner-t-name
              (let ([template (open-input-string t-template)])
                (check-equal? (~a (tokenize template))
                              (~a t-mock-token)
                              scanner-t-error-msg)))
             (test-case
              render-t-name
              (let ([rendered (open-output-string)])
                (render t-mock-token hash rendered)
                (check-equal? (get-output-string rendered)
                              t-expected
                              render-t-error-msg))))))]))


#lang racket

(require "../main.rkt")
(require "../macro-generate.rkt")

(js->racket-code "../vendor/urlshortener.v1.js")
;; (require/js "../vendor/urlshortener.v1.js")

(define orig-url "http://www.racket-lang.org/")
(define js-insert (urlshortener.url.insert #:longUrl orig-url
                                           #:key (api-key)))
(define short-url (dict-ref js-insert 'id))
(define js-get (urlshortener.url.get short-url
                                     #:key (api-key)))
(define long-url (dict-ref js-get 'longUrl))
(equal? orig-url long-url)

(js->scribble-code "../vendor/urlshortener.v1.js")

Update example of using the macro approach.

#lang racket

(require "../main.rkt")
(require "../macro-generate.rkt")

(js->racket-code "../vendor/urlshortener.v1.js")
;; (require/js "../vendor/urlshortener.v1.js")

(define orig-url "http://www.racket-lang.org/")
(define js-insert (urlshortener.url.insert #:longUrl orig-url
                                           #:key (api-key)))
(define short-url (dict-ref js-insert 'id))
(define js-get (urlshortener.url.get short-url
                                     #:key (api-key)))
(define long-url (dict-ref js-get 'longUrl))
(printf "~s was shortened to ~s, which expanded back to ~s: ~a"
        orig-url short-url long-url
        (if (equal? orig-url long-url) "Yay!" "Boo!"))

;;(js->scribble-code "../vendor/urlshortener.v1.js")


#lang scribble/doc
@(require "base.rkt")

@title{Acknowlegements}

The following people have contributed to RackUnit:

@itemize[
  @item{Robby Findler pushed me to release version 3}

  @item{Matt Jadud and his students at Olin College
  suggested renaming @racket[test/text-ui]}

  @item{Dave Gurnell reported a bug in check-not-exn and
  suggested improvements to RackUnit}

  @item{Danny Yoo reported a bug in and provided a fix for
    trim-current-directory}

  @item{Jacob Matthews and Guillaume Marceau for bug reports
    and fixes}

  @item{Eric Hanchow suggested test/text-ui return a useful
    result}

  @item{Ray Racine and Richard Cobbe provided require/expose}

  @item{John Clements suggested several new checks}

  @item{Jose A. Ortega Ruiz alerted me a problem in the
    packaging system and helped fix it.}

  @item{Sebastian H. Seidel provided help packaging RackUnit
    into a .plt}

  @item{Don Blaheta provided the method for grabbing line number
    and file name in checks}

  @item{Patrick Logan ported example.rkt to version 1.3}

  @item{The PLT team made Racket}

  @item{The Extreme Programming community started the whole
    testing framework thing}
]

Fix a typo in Eric Hanchrow's name.

#lang scribble/doc
@(require "base.rkt")

@title{Acknowlegements}

The following people have contributed to RackUnit:

@itemize[
  @item{Robby Findler pushed me to release version 3}

  @item{Matt Jadud and his students at Olin College
  suggested renaming @racket[test/text-ui]}

  @item{Dave Gurnell reported a bug in check-not-exn and
  suggested improvements to RackUnit}

  @item{Danny Yoo reported a bug in and provided a fix for
    trim-current-directory}

  @item{Jacob Matthews and Guillaume Marceau for bug reports
    and fixes}

  @item{Eric Hanchrow suggested test/text-ui return a useful
    result}

  @item{Ray Racine and Richard Cobbe provided require/expose}

  @item{John Clements suggested several new checks}

  @item{Jose A. Ortega Ruiz alerted me a problem in the
    packaging system and helped fix it.}

  @item{Sebastian H. Seidel provided help packaging RackUnit
    into a .plt}

  @item{Don Blaheta provided the method for grabbing line number
    and file name in checks}

  @item{Patrick Logan ported example.rkt to version 1.3}

  @item{The PLT team made Racket}

  @item{The Extreme Programming community started the whole
    testing framework thing}
]


#lang racket
(require racket/enter
         racket/help)

;; Set the printer:
(current-print (let ([pretty-printer
                      (lambda (v)
                        (unless (void? v)
                          (pretty-print v)))])
                 pretty-printer))

(provide (all-from-out racket
                       racket/enter
                       racket/help))

Make xrepl the default repl if it is installed

#lang racket
(require racket/enter
         racket/help)

;; Set the printer:
(current-print (let ([pretty-printer
                      (lambda (v)
                        (unless (void? v)
                          (pretty-print v)))])
                 pretty-printer))

(provide (all-from-out racket
                       racket/enter
                       racket/help))

;; Set the default replt to XREPL
(with-handlers ([exn:fail? void])
  (dynamic-require 'xrepl #f))


#lang racket/base
(require racket/tcp
         racket/list
         racket/match
         racket/port
         racket/contract)

(define (tcp-localhost-available?)
  (with-handlers
      ([exn? (λ (x) #f)])
    (define the-listener
      (tcp-listen 0 5 #t))
    (define-values (local-host port end-host end-port)
      (tcp-addresses the-listener #t))
    (thread
     (λ ()
       (tcp-accept the-listener)
       (tcp-close the-listener)))
    (tcp-connect "localhost" port)
    #t))

(provide
 (contract-out
  [tcp-localhost-available? (-> boolean?)]))

(module+ main
  (tcp-localhost-available?))

(module+ test (require (submod ".." main))) ; for raco test & drdr

Use the version of this file that just moved into the core.

#lang racket/base
(require tests/racket/net-available)
(provide tcp-localhost-available?)


#lang setup/infotab

(define scribblings '(("handin-server.scrbl" (multi-page))))

Revert "move the handin-server docs out of the user's space and into the plt/doc"

#lang setup/infotab

(define scribblings '(("handin-server.scrbl" (multi-page user-doc))))


#lang scribble/html

@require["templates.rkt"]

@page[#:title "Documentation"]{
 @div[class: "container"]{@a[href: "http://pkg-build.racket-lang.org/doc/user-guide/index.html"]{Documentation}}
}

Add better user guiee paper.

#lang scribble/html

@require["templates.rkt"]

@page[#:title "Documentation"]{
 @div[class: "container"]{
   @div[class: "jumbotron"]{
     @h1{User Guide}
     @a[href: "http://pkg-build.racket-lang.org/doc/user-guide/index.html"]{Documentation}}}}


#lang racket/base
(require rackunit/docs-complete)
(check-docs (quote typed/scheme))
(check-docs (quote typed/scheme/base))
(check-docs (quote typed/racket))
(check-docs (quote typed/racket/base))

Include `typed-scheme' language in doc check.

#lang racket/base
(require rackunit/docs-complete)
(check-docs (quote typed-scheme))
(check-docs (quote typed/scheme))
(check-docs (quote typed/scheme/base))
(check-docs (quote typed/racket))
(check-docs (quote typed/racket/base))


#lang info

(define collection 'multi)

(define build-deps '("net-doc"
                     "scheme-lib"
                     "srfi-lite-lib"
                     "compatibility-doc"
                     "r6rs-doc"
                     "srfi-doc"
                     "compatibility-lib"
                     "r6rs-lib"
                     "sandbox-lib"
                     "at-exp-lib"
                     "scribble-lib"
                     "typed-racket-lib"
                     "typed-racket-compatibility"
                     "racket-doc"))
(define deps '("base"))

(define pkg-desc "documentation part of \"typed-racket\"")

(define pkg-authors '(samth stamourv))

Update TR doc pkg dependencies

#lang info

(define collection 'multi)

(define build-deps '("net-doc"
                     "scheme-lib"
                     "srfi-lite-lib"
                     "compatibility-doc"
                     "r6rs-doc"
                     "srfi-doc"
                     "compatibility-lib"
                     "r6rs-lib"
                     "sandbox-lib"
                     "at-exp-lib"
                     "scribble-lib"
                     "pict-lib"
                     "typed-racket-lib"
                     "typed-racket-compatibility"
                     "racket-doc"))
(define deps '("base"))

(define pkg-desc "documentation part of \"typed-racket\"")

(define pkg-authors '(samth stamourv))


(require mzlib/process)

(define name (vector-ref (current-command-line-arguments) 0))

(system (format "csc -no-warnings -no-trace -no-lambda-info -optimize-level 3 -block ~a.sch"
                name))

Add -d0 flag to Chicken benchmarks.

(require mzlib/process)

(define name (vector-ref (current-command-line-arguments) 0))

(system (format "csc -no-warnings -no-trace -no-lambda-info -optimize-level 3 -block -d0 ~a.sch"
                name))


#lang at-exp s-exp "shared.rkt"

(require racket/string "data.rkt")

(define (in-ftp . paths)
  (string-join (cons "/var/ftp/pub/racket" paths) "/"))

(define docs       (symlink  (in-ftp "docs")))
(define installers (symlink  (in-ftp "installers")))

(provide index)
(define index
  (page #:link-title "Downloads"
    @ul{@li{Current @a[href: `(,installers "/recent")]{installers}
            (or @a[href: installers]{all versions}).}
        @li{Current documentation in
            @a[href: `(,docs "/recent/html")]{HTML} and in
            @a[href: `(,docs "/recent/pdf")]{PDF}
            (or @a[href: docs]{all versions}).}}))

Put a download button on the toplevel download page too.

#lang at-exp s-exp "shared.rkt"

(require racket/string "data.rkt" "../www/download.rkt")

(define (in-ftp . paths)
  (string-join (cons "/var/ftp/pub/racket" paths) "/"))

(define docs       (symlink  (in-ftp "docs")))
(define installers (symlink  (in-ftp "installers")))

(provide index)
(define index
  @page[#:link-title "Downloads"]{
    @div[style: "float: right;"]{@download-button}
    Use these links to browse the download directories directly:
    @ul{@li{Current @a[href: `(,installers "/recent")]{installers}
            (or @a[href: installers]{all versions}).}
        @li{Current documentation in
            @a[href: `(,docs "/recent/html")]{HTML} and in
            @a[href: `(,docs "/recent/pdf")]{PDF}
            (or @a[href: docs]{all versions}).}}})


#lang racket
(provide (except-out (all-from-out racket) #%module-begin))
(require racket/unsafe/ops (for-syntax racket/base racket/runtime-path syntax/parse))
(provide (all-from-out racket/unsafe/ops))
(provide (rename-out [modbeg #%module-begin]))

(begin-for-syntax
 (define-runtime-path stdlib.sch "./stdlib.rktl")
 (define-splicing-syntax-class stdlib
   [pattern (~seq (~and form #:stdlib))
            #:with e (datum->syntax #'form `(include (file ,(path->string stdlib.sch))))]
   [pattern (~seq) #:with e #'(begin)]))

(define-syntax (modbeg stx)
  (syntax-parse stx
    [(_ lib:stdlib forms ...)
     #`(#%plain-module-begin lib.e forms ...)]))

(module reader syntax/module-reader
  pycket)

Whitelist some mzscheme/r5rs functions for benchmarks in pycket-lang

#lang racket
(provide (except-out (all-from-out racket) #%module-begin))
(require racket/unsafe/ops (for-syntax racket/base racket/runtime-path syntax/parse))
(require (prefix-in r5: r5rs) (prefix-in mz: mzscheme))
(provide (all-from-out racket/unsafe/ops))
;; for now, white-listed for benchmarks.
(provide mz:call-with-output-file
         r5:lambda
         r5:define
         r5:lambda
         r5:apply
         r5:string->list
         r5:list->string
         r5:vector->list
         r5:list->vector
         r5:list
         r5:quote
         r5:quasiquote
         r5:unquote)
(provide (rename-out [modbeg #%module-begin]))

(begin-for-syntax
 (define-runtime-path stdlib.sch "./stdlib.rktl")
 (define-splicing-syntax-class stdlib
   [pattern (~seq (~and form #:stdlib))
            #:with e (datum->syntax #'form `(include (file ,(path->string stdlib.sch))))]
   [pattern (~seq) #:with e #'(begin)]))

(define-syntax (modbeg stx)
  (syntax-parse stx
    [(_ lib:stdlib forms ...)
     #`(#%plain-module-begin lib.e forms ...)]))

(module reader syntax/module-reader
  pycket)


#lang racket

(define (f2n c)
  (match c
    [#\( 1]
    [#\) -1]
    [_ 0]))
(define (calculate-floor s)
  (sum (map f2n (string->list s))))
(define (read-floor input-port)
  (let ([char (read-char input-port)])
    (if (eof-object? char)
        char
        (f2n char))))
(define (sum lst) (foldl + 0 lst))

(displayln (sum (port->list read-floor)))

Complete part 2 of day 1

#lang racket

(define (f2n c)
  (match c
    [#\( 1]
    [#\) -1]
    [_ 0]))

(define (read-floor input-port)
  (let ([char (read-char input-port)])
    (if (eof-object? char)
        char
        (f2n char))))

(define (follow lst value #:index [index 0] #:accumulator [accumulator 0])
  (if (null? lst)
      #f
      (begin
        (set! accumulator (+ (car lst) accumulator))
        (if (equal? accumulator value)
            index
            (follow (cdr lst) value #:index (add1 index) #:accumulator accumulator)))))

(module+ main
  (define lst (port->list read-floor))
  (displayln (format "Santa stopped floor ~a" (apply + lst)))
  (displayln (format "Santa first reaches the basement at position ~a" (add1 (follow lst -1)))))


#;
(
TR missed opt: invalid-fxquotient.rkt 10:21 (quotient fixnum-min -1) -- out of fixnum range
#f
)

#lang typed/racket/base

(define: fixnum-min : Nonpositive-Fixnum (assert (- (expt 2 30)) fixnum?))
(define: q : Natural (quotient fixnum-min -1)) ; this can't be optimized safely
(fixnum? q) ; should return #f

Fix test for invalid fixnum quotient optimization.

#;
(
TR missed opt: invalid-fxquotient.rkt 10:21 (quotient fixnum-min -1) -- out of fixnum range
#t
)

#lang typed/racket/base

(define: fixnum-min : Nonpositive-Fixnum (assert (- (expt 2 30)) fixnum?))
(define: q : Natural (quotient fixnum-min -1)) ; this can't be optimized safely
(= 1073741824 q)


#lang meta/web

(require "resources.rkt")

(define webchat-link
  "http://webchat.freenode.net?channels=racket&uio=OT10cnVlJjExPTIzNg6b")

(define irc-chat
  @page[#:title "IRC" #:part-of 'community]{
    @iframe[src: webchat-link width: "100%" height: "400"]})

(define irc-logs
  (let ()
    @plain[#:file "irc-logs/.htaccess"]{
      RewriteEngine on
      RewriteRule ^(.*)$ http://pre.racket-lang.org@;
         /irc-logs/@||racket/@|"$1"| [P]
    }
    (λ (text) @a[href: "irc-logs/"]{@text})))

(provide irc-quick)
(define (irc-quick)
  @parlist[@strong{Discussion Channel}
    @text{@irc-chat{Chat on IRC} in the @TT{@big{@strong{#racket}}} channel on
      @a[href: "http://freenode.net"]{@tt{freenode.net}} — an informal
      discussion channel for all things related to Racket.
      (@irc-logs{Browse the logs}.)}])

Use the internal machine name, in case "pre" moves elsewhere.

#lang meta/web

(require "resources.rkt")

(define webchat-link
  "http://webchat.freenode.net?channels=racket&uio=OT10cnVlJjExPTIzNg6b")

(define irc-chat
  @page[#:title "IRC" #:part-of 'community]{
    @iframe[src: webchat-link width: "100%" height: "400"]})

(define irc-logs
  (let ()
    @plain[#:file "irc-logs/.htaccess"]{
      RewriteEngine on
      RewriteRule ^(.*)$ http://lambda.racket-lang.org@;
         /irc-logs/@||racket/@|"$1"| [P]
    }
    (λ (text) @a[href: "irc-logs/"]{@text})))

(provide irc-quick)
(define (irc-quick)
  @parlist[@strong{Discussion Channel}
    @text{@irc-chat{Chat on IRC} in the @TT{@big{@strong{#racket}}} channel on
      @a[href: "http://freenode.net"]{@tt{freenode.net}} — an informal
      discussion channel for all things related to Racket.
      (@irc-logs{Browse the logs}.)}])


#lang racket/base
(require "test-util.rkt")

(parameterize ([current-contract-namespace
                (make-basic-contract-namespace 'racket/contract)])

  (test/spec-passed
   '∃1
   '(contract (new-∃/c 'pair)
              1
              'pos
              'neg))

  (test/neg-blame
   '∃2
   '((contract (-> (new-∃/c 'pair) any/c)
               (λ (x) x)
               'pos
               'neg)
     1))

  (test/spec-passed/result
   '∃3
   '(let ([pair (new-∃/c 'pair)])
      ((contract (-> (-> pair pair) any/c)
                 (λ (f) (f 11))
                 'pos
                 'neg)
       (λ (x) x)))
   11)

  (test/pos-blame
   '∀1
   '(contract (new-∀/c 'pair)
              1
              'pos
              'neg))

  (test/spec-passed
   '∀2
   '((contract (-> (new-∀/c 'pair) any/c)
               (λ (x) x)
               'pos
               'neg)
     1))

  (test/spec-passed/result
   '∀3
   '(let ([pair (new-∀/c 'pair)])
      ((contract (-> pair pair)
                 (λ (x) x)
                 'pos
                 'neg)
       11))
   11))

Fix test that is broken without space-efficient wrappers.

#lang racket/base
(require "test-util.rkt")

(parameterize ([current-contract-namespace
                (make-basic-contract-namespace 'racket/contract)])

  (test/spec-passed
   '∃1
   '(contract (new-∃/c 'pair)
              1
              'pos
              'neg))

  (test/neg-blame
   '∃2
   '((contract (-> (new-∃/c 'pair) any/c)
               (λ (x) x)
               'pos
               'neg)
     1))

  (test/spec-passed/result
   '∃3
   '(let ([pair (new-∃/c 'pair)])
      ((contract (-> (-> pair pair) any/c)
                 (λ (f) (f 11))
                 'pos
                 'neg)
       (λ (x) x)))
   11
   do-not-double-wrap)

  (test/pos-blame
   '∀1
   '(contract (new-∀/c 'pair)
              1
              'pos
              'neg))

  (test/spec-passed
   '∀2
   '((contract (-> (new-∀/c 'pair) any/c)
               (λ (x) x)
               'pos
               'neg)
     1))

  (test/spec-passed/result
   '∀3
   '(let ([pair (new-∀/c 'pair)])
      ((contract (-> pair pair)
                 (λ (x) x)
                 'pos
                 'neg)
       11))
   11
   do-not-double-wrap))


#lang scribble/doc
@(require scribble/manual scribble/eval "guide-utils.rkt")

@title[#:tag "macros" #:style 'toc]{Macros}

A @deftech{macro} is a syntactic form with an associated
@deftech{transformer} that @deftech{expands} the original form
into existing forms. To put it another way, a macro is an
extension to the Racket compiler. Most of the syntactic forms of
@racketmodname[racket/base] and @racketmodname[racket] are
actually macros that expand into a small set of core constructs.

Like many languages, Racket provides pattern-based macros that
make simple transformations easy to implement and reliable to
use. Racket also supports arbitrary macro transformers that are
implemented in Racket---or in a macro-extended variant of Racket.

@local-table-of-contents[]

@;------------------------------------------------------------------------
@include-section["pattern-macros.scrbl"]
@include-section["proc-macros.scrbl"]

Add a link to a Macro tutorial written by Greg Hendershott which helps new learners understand Racket macro better.

#lang scribble/doc
@(require scribble/manual scribble/eval "guide-utils.rkt")

@title[#:tag "macros" #:style 'toc]{Macros}

A @deftech{macro} is a syntactic form with an associated
@deftech{transformer} that @deftech{expands} the original form
into existing forms. To put it another way, a macro is an
extension to the Racket compiler. Most of the syntactic forms of
@racketmodname[racket/base] and @racketmodname[racket] are
actually macros that expand into a small set of core constructs.

Like many languages, Racket provides pattern-based macros that
make simple transformations easy to implement and reliable to
use. Racket also supports arbitrary macro transformers that are
implemented in Racket---or in a macro-extended variant of Racket.

(For a bottom-up introduction of Racket macro, you may refer to: @(hyperlink "http://www.greghendershott.com/fear-of-macros/" "Fear of Macros"))

@local-table-of-contents[]

@;------------------------------------------------------------------------
@include-section["pattern-macros.scrbl"]
@include-section["proc-macros.scrbl"]


#lang rosette/safe

(provide (all-defined-out))

(define (make-vector size init-val)
  (letrec ([f (lambda (l n) (if (> n 0) (f (cons init-val l) (- n 1)) l))])
    (list->vector (f '() size))))

(define-syntax-rule (make-memory hi-addr zero) (make-vector hi-addr zero))

(define-syntax-rule (memory-ref m a) (vector-ref m a))

(define-syntax-rule (memory-set! m a val) (vector-set! m a val))

(define-syntax-rule (memory-copy m) (vector-copy! m))

Fix typo bug in mem-simple

#lang rosette

(provide (all-defined-out))

(define (make-vector size init-val)
  (letrec ([f (lambda (l n) (if (> n 0) (f (cons init-val l) (- n 1)) l))])
    (list->vector (f '() size))))

(define-syntax-rule (make-memory hi-addr zero) (make-vector hi-addr zero))

(define-syntax-rule (memory-ref m a) (vector-ref m a))

(define-syntax-rule (memory-set! m a val) (vector-set! m a val))

(define-syntax-rule (memory-copy m) (vector-copy m))


#;
(exn-pred exn:fail:contract? ".*pair?.*" #rx".*contract.*\\(->.*")

#lang scheme/load

(module tree typed-scheme
 (define-type-alias Tree (Rec T (U (Pair T T) Number)))

 (: tree-sum (Tree -> Number))
 (define (tree-sum t)
   (cond
     [(number? t) t]
     [else (+ (tree-sum (car t))
              (tree-sum (cdr t)))]))

 (provide tree-sum))

(module client scheme
 (require 'tree)
 (define (try-it bad?)
   (if bad?
       (tree-sum (cons 5 #f))
       (tree-sum (cons 5 6))))
 (provide try-it))

(require 'client)

(try-it #t)

Fix error message pattern for use of `cons/c`.

#;
(exn-pred exn:fail:contract? ".*cons/c.*" #rx".*contract.*\\(->.*")

#lang scheme/load

(module tree typed-scheme
 (define-type-alias Tree (Rec T (U (Pair T T) Number)))

 (: tree-sum (Tree -> Number))
 (define (tree-sum t)
   (cond
     [(number? t) t]
     [else (+ (tree-sum (car t))
              (tree-sum (cdr t)))]))

 (provide tree-sum))

(module client scheme
 (require 'tree)
 (define (try-it bad?)
   (if bad?
       (tree-sum (cons 5 #f))
       (tree-sum (cons 5 6))))
 (provide try-it))

(require 'client)

(try-it #t)


#lang info

(define collection "slatex")

(define scribblings '(("slatex-wrap.scrbl" () (tool-library))))

;; (define tools (list (list "slatex-lang.rkt")))
;; (define tool-names (list "SLaTeX Language"))

(define mzscheme-launcher-names '("SLaTeX" "PDF SLaTeX"))
(define mzscheme-launcher-libraries '("slatex-launcher.rkt"
                                      "pdf-slatex-launcher.rkt"))
(define deps '("base"
               "compatibility-lib"))
(define build-deps '("racket-doc"
                     "scribble-lib"))

;; Make slatex.sty easier to find (for adding to TEXINPUTS)
;; by copying it to the "lib" directory:
(define copy-foreign-libs '("slatex.sty"))

Move slatex rubber support to lib directory on install.

#lang info

(define collection "slatex")

(define scribblings '(("slatex-wrap.scrbl" () (tool-library))))

;; (define tools (list (list "slatex-lang.rkt")))
;; (define tool-names (list "SLaTeX Language"))

(define mzscheme-launcher-names '("SLaTeX" "PDF SLaTeX"))
(define mzscheme-launcher-libraries '("slatex-launcher.rkt"
                                      "pdf-slatex-launcher.rkt"))
(define deps '("base"
               "compatibility-lib"))
(define build-deps '("racket-doc"
                     "scribble-lib"))

;; Make slatex.sty easier to find (for adding to TEXINPUTS)
;; by copying it to the "lib" directory. Same for rubber support:
(define copy-foreign-libs '("slatex.sty" "slatex.py"))


#lang racket/base

(require (for-syntax racket/base
                     ;; these requires are needed since their code
                     ;; appears in the residual program
                     "typecheck/renamer.rkt" "types/type-table.rkt")
         "private/base-special-env.rkt")

(provide (rename-out [module-begin #%module-begin]
                     [top-interaction #%top-interaction]
                     [#%plain-lambda lambda]
                     [#%app #%app]
                     [require require])
         with-type
         (for-syntax do-standard-inits))

(define-for-syntax (do-standard-inits)
  (initialize-special)
  ((dynamic-require 'typed-scheme/private/base-structs 'initialize-structs))
  ((dynamic-require 'typed-scheme/private/base-env-indexing 'initialize-indexing))
  ((dynamic-require 'typed-scheme/private/base-env 'init))
  ((dynamic-require 'typed-scheme/private/base-env-numeric 'init)))

(define-syntax (module-begin stx)
  (do-standard-inits)
  ((dynamic-require 'typed-scheme/core 'mb-core) stx))

(define-syntax (top-interaction stx)
  (do-standard-inits)
  ((dynamic-require 'typed-scheme/core 'ti-core) stx))

(define-syntax (with-type stx)
  (do-standard-inits)
  ((dynamic-require 'typed-scheme/core 'wt-core) stx))

Refactor to avoid duplicated code.

#lang racket/base

(require (for-syntax racket/base
                     ;; these requires are needed since their code
                     ;; appears in the residual program
                     "typecheck/renamer.rkt" "types/type-table.rkt" profile)
         "private/base-special-env.rkt" )

(provide (rename-out [module-begin #%module-begin]
                     [top-interaction #%top-interaction]
                     [#%plain-lambda lambda]
                     [#%app #%app]
                     [require require])
         with-type
         (for-syntax do-standard-inits))

(define-for-syntax (do-standard-inits)
  (initialize-special)
  ((dynamic-require 'typed-scheme/private/base-structs 'initialize-structs))
  ((dynamic-require 'typed-scheme/private/base-env-indexing 'initialize-indexing))
  ((dynamic-require 'typed-scheme/private/base-env 'init))
  ((dynamic-require 'typed-scheme/private/base-env-numeric 'init)))

(define-syntax-rule (drivers [name sym] ...)
  (begin
    (define-syntax (name stx)
      (do-standard-inits)
      ((dynamic-require 'typed-scheme/core 'sym) stx))
    ...))

(drivers [module-begin mb-core] [top-interaction ti-core] [with-type wt-core])


#lang racket

(provide alphatize)
(require racket/hash nanopass/base
         "langs.rkt")

(define-pass alphatize : Core (cst) -> Core ()
  (definitions
    (define (param-bindings params)
      (for/fold ([env (hash)])
                ([param params])
        (nanopass-case (Core Var) param
          [(lex ,n) (hash-set env n (gensym n))]
          [else env])))

    (define (block-bindings stmts)
      (for/fold ([env (hash)])
                ([stmt stmts])
        (nanopass-case (Core Stmt) stmt
          [(def (lex ,n) ,e) (hash-set env n (gensym n))]
          [else env]))))

  (Expr : Expr (cst env) -> Expr ()
    [(block ,s* ... ,e)
     (define env* (hash-union env (block-bindings s*)))
     `(block ,(map (λ (stmt) (Stmt stmt env*)) s*) ...
             ,(Expr e env*))]
    [(fn (,x* ...) ,e)
     (define env* (hash-union env (param-bindings x*)))
     `(fn (,(map (λ (var) (Var var env*)) x*) ...)
          ,(Expr e env*))])

  (Stmt : Stmt (cst env) -> Stmt ())

  (Var : Var (cst env) -> Var ()
    [(lex ,n) `(lex ,(hash-ref env n))])

  (Expr cst (hash)))

Fix variable shadowing in alphatize.

#lang racket

(provide alphatize)
(require racket/hash nanopass/base
         "langs.rkt")

(define-pass alphatize : Core (cst) -> Core ()
  (definitions
    (define (param-bindings params)
      (for/fold ([env (hash)])
                ([param params])
        (nanopass-case (Core Var) param
          [(lex ,n) (hash-set env n (gensym n))]
          [else env])))

    (define (block-bindings stmts)
      (for/fold ([env (hash)])
                ([stmt stmts])
        (nanopass-case (Core Stmt) stmt
          [(def (lex ,n) ,e) (hash-set env n (gensym n))]
          [else env])))

    (define (push-frame env bindings)
      (hash-union env bindings #:combine (λ (_ v) v))))

  (Expr : Expr (cst env) -> Expr ()
    [(block ,s* ... ,e)
     (define env* (push-frame env (block-bindings s*)))
     `(block ,(map (λ (stmt) (Stmt stmt env*)) s*) ...
             ,(Expr e env*))]
    [(fn (,x* ...) ,e)
     (define env* (push-frame env (param-bindings x*)))
     `(fn (,(map (λ (var) (Var var env*)) x*) ...)
          ,(Expr e env*))])

  (Stmt : Stmt (cst env) -> Stmt ())

  (Var : Var (cst env) -> Var ()
    [(lex ,n) `(lex ,(hash-ref env n))])

  (Expr cst (hash)))


#lang racket/base
(require syntax/modresolve)
(provide module-db)

;; A ModuleDB = hash[path/symbol => (U 'no-drop 'no-bypass)]
;;   'no-drop = must not be dropped or bypassed because of, eg, side effects
;;   'no-bypass = don't bypass in favor of private component modules
;;                but if the module is unused, can drop it
;;                (FIXME: replace with component module calculation and checking)

(define (make-module-db mod+config-list)
  (for/hash ([mod+config (in-list mod+config-list)])
    (values (resolve-module-path (car mod+config) #f) (cadr mod+config))))

;; module-db : ModuleDB
(define module-db
  (make-module-db
   '([racket/base                            no-bypass]
     [racket/contract/base                   no-bypass]
     [racket/gui                             no-bypass]
     [racket/match                           no-bypass]
     ['#%builtin                             no-drop]

     [typed-scheme/private/base-env          no-drop]
     [typed-scheme/private/base-special-env  no-drop]
     [typed-scheme/private/base-env-numeric  no-drop]
     [typed-scheme/private/base-env-indexing no-drop])))

Fix require analysis heuristics for TS -> TR.

#lang racket/base
(require syntax/modresolve)
(provide module-db)

;; A ModuleDB = hash[path/symbol => (U 'no-drop 'no-bypass)]
;;   'no-drop = must not be dropped or bypassed because of, eg, side effects
;;   'no-bypass = don't bypass in favor of private component modules
;;                but if the module is unused, can drop it
;;                (FIXME: replace with component module calculation and checking)

(define (make-module-db mod+config-list)
  (for/hash ([mod+config (in-list mod+config-list)])
    (values (resolve-module-path (car mod+config) #f) (cadr mod+config))))

;; module-db : ModuleDB
(define module-db
  (make-module-db
   '([racket/base                            no-bypass]
     [racket/contract/base                   no-bypass]
     [racket/gui                             no-bypass]
     [racket/match                           no-bypass]
     ['#%builtin                             no-drop]

     [typed-racket/private/base-env          no-drop]
     [typed-racket/private/base-special-env  no-drop]
     [typed-racket/private/base-env-numeric  no-drop]
     [typed-racket/private/base-env-indexing no-drop])))


#lang scribble/doc
@(require scribble/manual
          scribble/bnf
          "common.rkt"
          (for-label racket/base))

@title[#:tag "read"]{@exec{raco read}: Reading and Pretty-Printing}

@; to associate `history` to the right package:
@(declare-exporting compiler/commands/read)

The @exec{raco expand} command @racket[read]s and pretty-prints the
contents of the given files. This command is useful for showing
how a @tt{#reader} or @hash-lang[]-based reader extension converts
input to an S-expression. It is also useful for pretty-printing a term
that is already in S-expression form.

Command-line flags:

@itemlist[
  @item{@Flag{n} @nonterm{n} or @DFlag{columns} @nonterm{n}  --- format output for a display with @nonterm{n} columns}
  @item{@Flag{h} or @DFlag{help} --- show help information for this command}
  @item{@DFlag{} --- do not treat remaining arguments as switches}
]

@history[#:added "1.3"]

Fix name of command in docs.

#lang scribble/doc
@(require scribble/manual
          scribble/bnf
          "common.rkt"
          (for-label racket/base))

@title[#:tag "read"]{@exec{raco read}: Reading and Pretty-Printing}

@; to associate `history` to the right package:
@(declare-exporting compiler/commands/read)

The @exec{raco read} command @racket[read]s and pretty-prints the
contents of the given files. This command is useful for showing
how a @tt{#reader} or @hash-lang[]-based reader extension converts
input to an S-expression. It is also useful for pretty-printing a term
that is already in S-expression form.

Command-line flags:

@itemlist[
  @item{@Flag{n} @nonterm{n} or @DFlag{columns} @nonterm{n}  --- format output for a display with @nonterm{n} columns}
  @item{@Flag{h} or @DFlag{help} --- show help information for this command}
  @item{@DFlag{} --- do not treat remaining arguments as switches}
]

@history[#:added "1.3"]


#;
(exn-pred 1)
#lang typed/racket

;; make sure letrec takes into account that some bidings may be undefined

(+ (letrec: ([x : Float x]) x) 1) ; PR 11511

Test for errors in rhs.

#;
(exn-pred 2)
#lang typed/racket

;; make sure letrec takes into account that some bidings may be undefined

(+ (letrec: ([x : Float x]) x) 1) ; PR 11511

(letrec: ([x : Float (+ x 1)]) 0) ; error in rhs


#lang racket

#|
   Copyright 2016-2017 Leif Andersen

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
|#

(require rackunit
         racket/gui/base
         "../player.rkt"
         (prefix-in green: "green.vid"))

(let ()
  (define p (new video-player% [video green:vid]))
  (send p show #f))

Add regression tests for bug stephen found.

#lang racket

#|
   Copyright 2016-2017 Leif Andersen

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
|#

(require rackunit
         racket/gui/base
         "../player.rkt"
         (prefix-in green: "green.vid"))

(let ()
  (define p (new video-player% [video green:vid]))
  (send p show #f)
  (check-true (>= (send p get-video-length) 9999))
  (send p stop)
  (check-true (send p is-stopped?))
  (send p seek 10)
  (check-equal? (send p get-position) 10)
  (send p play)
  (check-false (send p is-stopped?))
  (check-equal? (send p get-fps) 25))


#lang racket/base
(provide underscore-allowed)
(define underscore-allowed '(any number string variable variable-not-otherwise-mentioned natural integer real))

Make sure the Redex pattern language's 'boolean' is rendered as a nonterminal

#lang racket/base
(provide underscore-allowed)
(define underscore-allowed '(any number string variable variable-not-otherwise-mentioned natural integer real boolean))


#lang racket

(require rackunit "compiler.rkt")
(require rackunit/text-ui)

(define (run prg)
  (with-input-from-string (go-run (kashmir-compile-prg prg))
    (lambda () (read))))

(define compiler-tests
  (test-suite
   "compiler"

   (test-case
    "int literal"
    (check-equal?
     (run 123)
     123))

   (test-case
    "bool literal"
    (check-equal?
     (run 'true)
     'true))

   (test-case
    "lambda -> func"
    (check-equal?
     (kashmir-compile-expr
      '(lambda ([q : int]) q))
     "(func (q int) int {\nreturn q\n})"))

   (test-case
    "partial application"
    (check-equal?
     (run '(((lambda (x) (lambda (y) x)) 1) 2))
     1))

   (test-case
    "let"
    (check-equal?
     (run '(let (x 1) ((+ x) 2)))
     3))

   ))

(run-tests compiler-tests)

Add test for higher order functions and app

#lang racket

(require rackunit "compiler.rkt")
(require rackunit/text-ui)

(define (run prg)
  (with-input-from-string (go-run (kashmir-compile-prg prg))
    (lambda () (read))))

(define compiler-tests
  (test-suite
   "compiler"

   (test-case
    "int literal"
    (check-equal?
     (run 123)
     123))

   (test-case
    "bool literal"
    (check-equal?
     (run 'true)
     'true))

   (test-case
    "lambda -> func"
    (check-equal?
     (kashmir-compile-expr
      '(lambda ([q : int]) q))
     "(func (q int) int {\nreturn q\n})"))

   (test-case
    "partial application"
    (check-equal?
     (run '(((lambda (x) (lambda (y) x)) 1) 2))
     1))

   (test-case
    "let"
    (check-equal?
     (run '(let (x 1) ((+ x) 2)))
     3))

   (test-case
    "higher-order functions"
    (check-equal?
     (run '(((lambda (x) (lambda (y) (x y))) (lambda (x) x)) 1))
     1))

   ))

(run-tests compiler-tests)


#lang racket/base
(require pkg/path
         setup/dirs)

(module+ test
  (require rackunit)

  (check-equal? (path->pkg (collection-file-path "path.rkt" "tests" "pkg"))
                "racket-test")
  (check-equal? (call-with-values
                    (lambda () (path->pkg+subpath (collection-file-path "path.rkt" "tests" "pkg")))
                  list)
                (list "racket-test" (build-path "tests" "pkg" "path.rkt")))
  (check-equal? (call-with-values
                    (lambda () (path->pkg+subpath+collect (collection-file-path "path.rkt" "tests" "pkg")))
                  list)
                (list "racket-test" (build-path "tests" "pkg" "path.rkt") #f))

  (check-equal? (path->pkg (find-system-path 'temp-dir))
                #f)

  (check-equal? (path->pkg (build-path (find-pkgs-dir) "pkgs.rktd"))
                #f)
  (check-equal? (path->pkg (find-pkgs-dir))
                #f)

  (check-equal? (call-with-values
                    (lambda () (path->pkg+subpath+collect (collection-file-path "serve-catalog.rkt" "distro-build")))
                  list)
                (list "distro-build-server" (build-path "serve-catalog.rkt") "distro-build")))

Fix test that used `distro-build`.

#lang racket/base
(require pkg/path
         setup/dirs)

(module+ test
  (require rackunit)

  (check-equal? (path->pkg (collection-file-path "path.rkt" "tests" "pkg"))
                "racket-test")
  (check-equal? (call-with-values
                    (lambda () (path->pkg+subpath (collection-file-path "path.rkt" "tests" "pkg")))
                  list)
                (list "racket-test" (build-path "tests" "pkg" "path.rkt")))
  (check-equal? (call-with-values
                    (lambda () (path->pkg+subpath+collect (collection-file-path "path.rkt" "tests" "pkg")))
                  list)
                (list "racket-test" (build-path "tests" "pkg" "path.rkt") #f))

  (check-equal? (path->pkg (find-system-path 'temp-dir))
                #f)

  (check-equal? (path->pkg (build-path (find-pkgs-dir) "pkgs.rktd"))
                #f)
  (check-equal? (path->pkg (find-pkgs-dir))
                #f)

  (check-equal? (call-with-values
                    (lambda () (path->pkg+subpath+collect (collection-file-path "info.rkt" "icons")))
                  list)
                (list "icons" (build-path "info.rkt") "icons")))


#;
(exn-pred exn:fail:contract:arity?)
#lang racket/load

;; fail version

(module example typed/racket
  ;; coerces into unapplicable function
  (: id (Procedure -> Procedure))
  (define (id x) x)

  (: f (Integer -> Integer))
  (define (f x) (+ x 1))

  (define g (id f))

  ;; contract here should make sure g is not applicable
  (provide g))

(require 'example)

;; g should now be unapplicable via case-> contract
(g 3)

Change exception predicate for a test

#;
(exn-pred exn:fail:contract?)
#lang racket

;; fail version

(module example typed/racket
  ;; coerces into unapplicable function
  (: id (Procedure -> Procedure))
  (define (id x) x)

  (: f (Integer -> Integer))
  (define (f x) (+ x 1))

  (define g (id f))

  ;; contract here should make sure g is not applicable
  (provide g))

(require 'example)

;; g should now be unapplicable via case-> contract
(g 3)


#lang reader "website.rkt"

@(require "logo/logo.rkt")

@page[#:title "Main"]{
 Hello Video!
}

Add link to source code.

#lang reader "website.rkt"

@(require "logo/logo.rkt")

@page[#:title "Main"]{
 @div[class: "jumbotron"]{
  @div[class: "container"]{
   @div[class: "splash"]{
    @center{Video}
    @center{
     @a[class: "btn-oval btn btn-default btn-lg"
        href: "http://github.com/videolang/video"
        role: "button"]{
      Get Started}}}}}}


#lang reader "website.rkt"

@(require "logo/logo.rkt")

@page[#:title "Main"]{
 @div[class: "jumbotron"]{
  @div[class: "container"]{
   @div[class: "splash"]{
    @center{@img[src: big-logo alt: "Video" height: 200 width: 533]}
    @center{@h1{Video}}
    @h2{A Language for Making Movies}
    @p{@b{Video} is a language for making movies. It combines
     the power of a traditional video editor with the
     capabilities of a full programming language. Video
     integrates with the Racket ecosystem and extensions for
     DrRacket to transform it into a non-linear video editor.}
    @center{
     @a[class: "btn-oval btn btn-default btn-lg"
        href: "download.html"
        role: "button"]{
      Get Started}}
    @br{}
    @center{
     @a[class: "btn-snd-oval btn btn-default btn-lg"
        href: "https://twitter.com/videolang"
        role: "button"]{
      Follow us on Twitter}
     @center{
     @a[class: "btn-snd-oval btn btn-default btn-lg"
        href: "https://www.redbubble.com/people/leifandersen/works/30461319-video-lang-swag"
        role: "button"]{
        Get Video Swag}}}}}}}

Update title of main page.

#lang reader "website.rkt"

@(require "logo/logo.rkt")

@page[#:title "A Language for Multimedia Creation"]{
 @div[class: "jumbotron"]{
  @div[class: "container"]{
   @div[class: "splash"]{
    @center{@img[src: big-logo alt: "Video" height: 200 width: 533]}
    @center{@h1{Video}}
    @h2{A Language for Making Movies}
    @p{@b{Video} is a language for making movies. It combines
     the power of a traditional video editor with the
     capabilities of a full programming language. Video
     integrates with the Racket ecosystem and extensions for
     DrRacket to transform it into a non-linear video editor.}
    @center{
     @a[class: "btn-oval btn btn-default btn-lg"
        href: "download.html"
        role: "button"]{
      Get Started}}
    @br{}
    @center{
     @a[class: "btn-snd-oval btn btn-default btn-lg"
        href: "https://twitter.com/videolang"
        role: "button"]{
      Follow us on Twitter}
     @center{
     @a[class: "btn-snd-oval btn btn-default btn-lg"
        href: "https://www.redbubble.com/people/leifandersen/works/30461319-video-lang-swag"
        role: "button"]{
        Get Video Swag}}}}}}}


#lang scribble/manual
@(require scribble/bnf "utils.rkt")

@title{Scribble: The Racket Documentation Tool}

@author["Matthew Flatt" "Eli Barzilay"]

Scribble is a collection of tools for creating prose
documents---papers, books, library documentation, etc.---in HTML or
PDF (via Latex) form. More generally, Scribble helps you write
programs that are rich in textual content, whether the content is
prose to be typeset or any other form of text to be generated
programmatically.

This document is itself written using Scribble. You can see its source
at
@(let ([url "http://git.racket-lang.org/plt/tree/HEAD:/collects/scribblings/scribble"])
   (link url url)),
starting with the @filepath{scribble.scrbl} file.

@table-of-contents[]

@; ------------------------------------------------------------------------
@include-section["how-to-paper.scrbl"]
@include-section["reader.scrbl"]
@include-section["generic.scrbl"]
@include-section["plt.scrbl"]
@include-section["lp.scrbl"]
@include-section["text.scrbl"]
@include-section["internals.scrbl"]
@include-section["running.scrbl"]

@index-section[]

Update documentation source location link

#lang scribble/manual
@(require scribble/bnf "utils.rkt")

@title{Scribble: The Racket Documentation Tool}

@author["Matthew Flatt" "Eli Barzilay"]

Scribble is a collection of tools for creating prose
documents---papers, books, library documentation, etc.---in HTML or
PDF (via Latex) form. More generally, Scribble helps you write
programs that are rich in textual content, whether the content is
prose to be typeset or any other form of text to be generated
programmatically.

This document is itself written using Scribble. You can see its source
at
@(let ([url "http://git.racket-lang.org/plt/tree/HEAD:/pkgs/scribble-pkgs/scribble-doc/scribblings/scribble"])
   (link url url)),
starting with the @filepath{scribble.scrbl} file.

@table-of-contents[]

@; ------------------------------------------------------------------------
@include-section["how-to-paper.scrbl"]
@include-section["reader.scrbl"]
@include-section["generic.scrbl"]
@include-section["plt.scrbl"]
@include-section["lp.scrbl"]
@include-section["text.scrbl"]
@include-section["internals.scrbl"]
@include-section["running.scrbl"]

@index-section[]


#lang info

(define scribblings '(("scribblings/syntax.scrbl" (multi-page))))

(define test-responsibles '((all mflatt)))

Add doc category for syntax collection docs

#lang info

(define scribblings '(("scribblings/syntax.scrbl" (multi-page) ("Syntax Extensions"))))

(define test-responsibles '((all mflatt)))


#lang plai

(define (mconcat lst1 lst2)
  (cond
    [(empty? lst2) lst1]
    [(empty? lst1) lst2]
    [else (mconcatAux (reversa lst1 '()) lst2)]))

(define (mconcatAux lst1 lst2)
  (cond
    [(empty? lst1) lst2]
    [else (mconcatAux (cdr lst1) (cons (car lst1) lst2))]))

(define (reversa lst1 lst2)
  (cond
    [(empty? lst1) lst2]
    [else(reversa (cdr lst1)(cons (car lst1) lst2))]))

(test (mconcat '(1 2) '(3 4)) '(1 2 3 4))
(test (mconcat '(1 2 3 4 5 6) '()) '(1 2 3 4 5 6))
(test (mconcat '() '(3 4 d s w)) '(3 4 d s w))
(test (mconcat '() '()) '())
(test (mconcat '(a b c d e) '(1 2 3 4 5)) '(a b c d e 1 2 3 4 5))

Set print only errors for class notes.

#lang plai

(print-only-errors true)

(define (mconcat lst1 lst2)
  (cond
    [(empty? lst2) lst1]
    [(empty? lst1) lst2]
    [else (mconcatAux (reversa lst1 '()) lst2)]))

(define (mconcatAux lst1 lst2)
  (cond
    [(empty? lst1) lst2]
    [else (mconcatAux (cdr lst1) (cons (car lst1) lst2))]))

(define (reversa lst1 lst2)
  (cond
    [(empty? lst1) lst2]
    [else(reversa (cdr lst1)(cons (car lst1) lst2))]))

(test (mconcat '(1 2) '(3 4)) '(1 2 3 4))
(test (mconcat '(1 2 3 4 5 6) '()) '(1 2 3 4 5 6))
(test (mconcat '() '(3 4 d s w)) '(3 4 d s w))
(test (mconcat '() '()) '())
(test (mconcat '(a b c d e) '(1 2 3 4 5)) '(a b c d e 1 2 3 4 5))


#lang info

(define collection 'multi)

(define name "collections")
(define version "1.3.1")

(define deps
  '(["base" #:version "6.2"]
    "curly-fn"
    ["functional-lib" #:version "0.3.1"]
    "match-plus"
    "rackunit-lib"
    "static-rename"
    "unstable-list-lib"))
(define build-deps
  '("functional-doc"
    "racket-doc"
    "scribble-lib"))

Replace curly-fn dependency with curly-fn-lib

#lang info

(define collection 'multi)

(define name "collections")
(define version "1.3.1")

(define deps
  '(["base" #:version "6.2"]
    "curly-fn-lib"
    ["functional-lib" #:version "0.3.1"]
    "match-plus"
    "rackunit-lib"
    "static-rename"
    "unstable-list-lib"))
(define build-deps
  '("functional-doc"
    "racket-doc"
    "scribble-lib"))


#lang racket/unit

(require "../utils/utils.rkt"
         racket/match
         (typecheck signatures tc-funapp)
         (types base-abbrev utils type-table)
         (rep type-rep)
         (utils tc-utils))

(import tc-expr^)
(export tc-send^)

(define/cond-contract (tc/send form rcvr method args [expected #f])
  (-->* (syntax? syntax? syntax? syntax?) ((-or/c tc-results/c #f)) tc-results/c)
  (match (tc-expr rcvr)
    [(tc-result1: (Instance: (and c (Class: _ _ methods))))
     (match (tc-expr method)
       [(tc-result1: (Value: (? symbol? s)))
        (let* ([ftype (cond [(assq s methods) => cadr]
                            [else (tc-error/expr "send: method ~a not understood by class ~a" s c)])]
               [retval (tc/funapp rcvr args (ret ftype) (map tc-expr (syntax->list args)) expected)])
          (add-typeof-expr form retval)
          retval)]
       [(tc-result1: t) (int-err "non-symbol methods not supported by Typed Racket: ~a" t)])]
    [(tc-result1: t) (tc-error/expr #:return (or expected (ret -Bottom)) "send: expected a class instance, got ~a" t)]))

Remove contract on unit-exported definition.

#lang racket/unit

(require "../utils/utils.rkt"
         racket/match
         (typecheck signatures tc-funapp)
         (types base-abbrev utils type-table)
         (rep type-rep)
         (utils tc-utils))

(import tc-expr^)
(export tc-send^)

(define (tc/send form rcvr method args [expected #f])
  (match (tc-expr rcvr)
    [(tc-result1: (Instance: (and c (Class: _ _ methods))))
     (match (tc-expr method)
       [(tc-result1: (Value: (? symbol? s)))
        (let* ([ftype (cond [(assq s methods) => cadr]
                            [else (tc-error/expr "send: method ~a not understood by class ~a" s c)])]
               [retval (tc/funapp rcvr args (ret ftype) (map tc-expr (syntax->list args)) expected)])
          (add-typeof-expr form retval)
          retval)]
       [(tc-result1: t) (int-err "non-symbol methods not supported by Typed Racket: ~a" t)])]
    [(tc-result1: t) (tc-error/expr #:return (or expected (ret -Bottom)) "send: expected a class instance, got ~a" t)]))


#lang info

(define collection 'multi)

(define name "alexis-collections")
(define version "0.2.0")

(define deps
  '("base"))
(define build-deps
  '("scribble-lib"
    "racket-doc"
    "cover"))

Add a dependency on alexis-util

#lang info

(define collection 'multi)

(define name "alexis-collections")
(define version "0.2.0")

(define deps
  '("base"
    "alexis-util"))
(define build-deps
  '("scribble-lib"
    "racket-doc"
    "cover"))