tweaks

tweaks

-----------------------------------------------------
-- Prelude-like functions

data Arr a m b = Arr (a -> b)

apply :: Arr a c d -> a -> d
apply (Arr f) x = f x

maybeM = Monad Just bind fail
  where fail s = Nothing
        bind Nothing g = Nothing
        bind (Just x) g = g x

monad maybeM

data Rec :: Row Tag *0 ~> *0 where
  RNil :: Rec RNil
  RCons :: Label a -> b -> Rec r -> Rec (RCons a b r)
 deriving Record()

----------------------------------------------------------
-- New kinds and operations on them

kind Set = Univ | Empty Tag | Times Set Set | Plus Set Set
kind Termination = Total | Partial

lub:: Termination ~> Termination ~> Termination
{lub Total x} = x
{lub Partial x} = Partial

allU:: Set ~> Termination
{allU Univ} = Total
{allU (Empty a)} = Partial
{allU (Times x y)} = {lub {allU x} {allU y}}
{allU (Plus x y)} =  {lub {allU x} {allU y}}

union:: Set ~> Set ~> Set
{union Univ a} = Univ
{union (Times p1 p2) (Times q1 q2)} = Times {union p1 q1} {union p2 q2}
{union (Times a b) (Empty c)} = Times a b
{union (Times a b) Univ} = Univ
{union (Plus p1 p2) (Plus q1 q2)} = Plus {union p1 q1} {union p2 q2}
{union (Plus p1 p2) (Empty c)} = Plus p1 p2
{union (Plus p1 p2) Univ} = Univ
{union (Empty a) x} = x

------------------------------------------------------------
-- Judgements for well-typed patterns and terms

data Prim:: *0 ~> *0 where
  Add :: Prim (Arr Int Total (Arr Int Total Int))
  Sub :: Prim (Arr Int Total (Arr Int Total Int))
  Mul :: Prim (Arr Int Total (Arr Int Total Int))
  Div :: Prim (Arr Int Total (Arr Int Partial Int))

data Pat:: Set ~> *0 ~> Row Tag *0 ~> Row Tag *0 ~> *0 where
  Pvar :: Label a -> Pat Univ t r (RCons a t r)
  Ppair:: Pat s1 a g1 g2 -> Pat s2 b g2 g3 ->
          Pat (Times s1 s2) (a,b) g1 g3
  Pwild:: Pat Univ t r r
  Pnil :: Pat (Plus Univ (Empty `Cons)) [a] r r
  Pcons:: Pat s1 a g1 g2 -> Pat s2 [a] g2 g3 ->
          Pat (Plus (Empty `Nil) (Times s1 s2)) [a] g1 g3

data Exp:: *0 ~> Row Tag *0 ~> Termination ~> *0 where
  Var:: Label a -> Exp t (RCons a t r) Total
  Shift:: Exp t g m -> Exp t (RCons a b g) m
  Const:: Int -> Exp Int g Total
  Oper:: Prim t -> Exp t g Total
  Pair:: Exp x g m -> Exp y g n -> Exp (x,y) g {lub m n}
  App:: Exp (Arr x m b) g n -> Exp x g p -> Exp b g {lub m {lub n p}}
  Abs:: Clause xx (Arr a i b) g1 -> Exp (Arr a {lub {allU xx} i} b) g1 Total
  Nil:: Exp [a] g Total
  Cons:: Exp a g m -> Exp [a] g n -> Exp [a] g {lub m n}
  Undefined:: Exp a g Partial
  Letrec :: Label f ->
            Exp (Arr a Partial b) (RCons f (Arr a Partial b) r) m ->
            Exp c (RCons f (Arr a Partial b) r) n ->
            Exp c r {lub m n}
  Cata :: Exp (Arr a m1 (Arr b m2 b)) r m3 ->
          Exp b r m4 ->
          Exp [a] r m5 ->
          Exp b r {lub m1 {lub m2 {lub m3 {lub m4 m5}}}}

data Clause:: Set ~> *0 ~> Row Tag *0 ~> *0 where
  Last:: (Pat s1 a g1 g2,Exp b g2 m) -> Clause s1 (Arr a m b) g1
  Next:: (Pat s1 a g1 g2,Exp b g2 m) ->
         Clause s (Arr a n b) g1 ->
         Clause {union s1 s} (Arr a {lub m n} b) g1

---------------------------------------------------------------
-- evaluation for well-typed terms

liftOp f = Arr (\ x -> Arr (\ y -> f x y))

evalOp :: Prim t -> t
evalOp Add = liftOp (+)
evalOp Sub = liftOp (-)
evalOp Mul = liftOp (*)
evalOp Div = liftOp div

eval :: Exp t r m -> Rec r -> t
eval (Var a) (RCons b v r) = v
eval (Shift x) (RCons b v r) = eval x r
eval (Const n) r = n
eval (Oper p) r = evalOp p
eval (Pair x y) r = (eval x r, eval y r)
eval (App f x) r = apply (eval f r) (eval x r)
eval (Abs cl) r = Arr (evalClause cl r)
eval Nil r = []
eval (Cons x xs) r = (eval x r):(eval xs r)
eval Undefined r = error "Undefined"
eval (Letrec f fun body) r =
  let r2 = RCons f (eval fun r2) r
  in eval body r2
eval (Cata phi base x) r =
   let phi' = eval phi r
       base' = eval base r
       cata [] = base'
       cata (x:xs) = phi' `apply` x `apply` (cata xs)
    in cata (eval x r)

evalPat :: Pat s t g1 g2 -> t -> Rec g1 -> Maybe (Rec g2)
evalPat (Pvar s) v r = return(RCons s v r)
evalPat (Ppair p q) (x,y) r =
  do { r1 <- evalPat p x r; evalPat q y r1}
evalPat (Pwild {- m -} ) v r = return r
evalPat Pnil [] r = return r
evalPat Pnil (x:xs) r = Nothing
evalPat (Pcons x y) (z:zs) r =
  do { r1 <- evalPat x z r; evalPat y zs r1}
evalPat (Pcons x y) [] r1 = Nothing

evalClause :: Clause s (Arr a m b) g1 -> Rec g1 -> (a -> b)
evalClause (Next (p,e) m) r v =
  case evalPat p v r of
    Nothing -> evalClause m r v
    Just r2 -> eval e r2
evalClause (Last (p,e)) r v =
  case evalPat p v r of
    Nothing -> error "Pattern Match Failure"
    Just r2 -> eval e r2

--------------------------------------------------
-- Some examples

c1 = (Pnil,Const 0)
c2 = (Pcons (Pvar `x) Pwild,Var `x)
c3 = (Pwild, Undefined)
c4 = (Pcons (Pvar `x) (Pcons (Pvar `y) (Pvar `ys)),Shift(Shift(Var `x)))

d1 = Next c1 (Last c2)
d2 = Next c2 (Last c3)
d3 = Last c2
d4 = Last c3
d5 = Next c1 (Last c4)
d6 = Next c2 d5

-- abs :: Label a -> Exp b (RCons (Has a c) d) e -> Exp (Arr c e b) d f
abs x e = Abs(Last (Pvar x,e))

add x y = App (App (Oper Add) x) y
times x y = App (App (Oper Mul) x) y
sub x y = App (App (Oper Sub) x) y

-- let `f = (\ `x -> (1 + ((Sh `f) `x)))
-- in (`f 3)
zz:: Exp Int g Partial
zz =
  Letrec `f (abs `x (App (App (Oper Add) (Const 1))
                         (App (Shift (Var `f)) (Var `x))))
            (App (Var `f) (Const 3))

-- let `length = (\ [] -> 0
--                  (`x:`xs) -> (1 + ((Sh (Sh `length)) `xs)))
-- in `length
length1 :: Exp (Arr [a] Partial Int) b Total
length1 = Letrec `length (Abs (Next (Pnil,Const 0)
                              (Last (Pcons (Pvar `x) (Pvar `xs),
                                     add (Const 1)
                                          (App (Shift(Shift(Var `length)))
                                               (Var `xs))))))
                         (Var `length)

-- \ [] -> 0
--   (`x:_) -> `x
t1x :: Exp (Arr [Int] Total Int) a Total
t1x = Abs d1

-- \ (`x:_) -> `x
--   _ -> undefined
t2x :: Exp (Arr [a] Partial a) b Total
t2x = Abs d2

---- This should fail
##test "Unifier shows too polymorphic"
  t2xBad :: Exp (Arr [a] c a) b Total
  t2xBad = Abs d2

-- \ (`x:_) -> `x
t3x :: Exp (Arr [a] Partial a) b Total
t3x = Abs d3

-- \ _ -> undefined
t4x :: Exp (Arr a Partial b) c Total
t4x = Abs d4

-- \ [] -> 0
--   (`x:(`y:`ys)) -> (Sh (Sh `x))
t5x :: Exp (Arr [Int] Partial Int) a Total
t5x = Abs d5

-- \ (`x:_) -> `x
--   [] -> 0
--   (`x:(`y:`ys)) -> (Sh (Sh `x))
t6x :: Exp (Arr [Int] Total Int) a Total
t6x = Abs d6

-- \ `f -> \ `g -> \ `x -> ((Sh (Sh `f)) ((Sh `g) `x))

-- compose :: Exp (Arr (Arr a b c) d (Arr (Arr e b a) f (Arr e b c))) g h
compose = abs `f (abs `g (abs `x (App (Shift(Shift (Var `f))) (App (Shift (Var `g)) (Var `x)))))

-- \ x -> \ y -> Add y 1
succ = abs `x (abs `y (App (App (Oper Add) (Var `y)) (Const 1)))

length :: Exp (Arr [a] Total Int) g Total
length =
   abs `x (Cata succ
                (Const 0)
                (Var `x))

xs = Cons (Const 1) (Cons (Const 3) (Cons (Const 5) Nil))

-------------------------------------------------
-- printing terms

sp :: Pat a b c d -> String
sp (Pvar s) = show s
sp (Ppair x y) = "("++sp x++","++sp y++")"
sp Pwild = "_"
sp Pnil = "[]"
sp (Pcons x xs) = "("++sp x++":"++sp xs++")"

sc :: Clause a b c -> String
sc (Last(p,e)) = sp p++" -> "++se e
sc (Next (p,e) cs) = sp p++" -> "++se e++"\n--   "++sc cs

se :: Exp a b c -> String
se (Var x) = show x
se (Shift x) = "(Sh "++se x++")"
se (Const n) = show n
se (Pair x y) = "("++se x++","++se y++")"
se (App (App (Oper f) x) y) = "("++se x++so f++se y++")"
se (App x y) = "("++se x++" "++se y++")"
se (Abs cl) = "(\\ "++sc cl++")"
se Nil = "[]"
se (Cons x xs) = "("++se x++":"++se xs++")"
se Undefined = "undefined"
se (Letrec f x y) =
  "-- let "++show f++" = "++se x++"\n   in "++se y++"\n"
se (Oper Add) = "(+)"
se (Oper Sub) = "(-)"
se (Oper Mul) = "(*)"
se (Oper Div) = "div"
se (Cata phi b xs) = "(cata "++se phi++" "++se b++" "++se xs++")"

so :: Prim t -> String
so Add = " + "
so Sub = " - "
so Mul = " * "
so Div = " / "

f x = putStr ("\n"++(se x)++"\n")

-----------------------------------------------------
-- Prelude-like functions

data Arr a m b = Arr (a -> b)

apply :: Arr a c d -> a -> d
apply (Arr f) x = f x

maybeM =  (Monad Just bind fail)
  where return x = Just x
        fail s = Nothing
        bind Nothing g = Nothing
        bind (Just x) g = g x

monad maybeM

data Rec :: Row Tag *0 ~> *0 where
  RNil :: Rec RNil
  RCons :: Label a -> b -> Rec r -> Rec (RCons a b r)

----------------------------------------------------------
-- New kinds and operations on them

kind Set = Univ | Empty Tag | Times Set Set | Plus Set Set
kind Termination = Total | Partial

lub:: Termination ~> Termination ~> Termination
{lub Total x} = x
{lub Partial x} = Partial

allU:: Set ~> Termination
{allU Univ} = Total
{allU (Empty a)} = Partial
{allU (Times x y)} = {lub {allU x} {allU y}}
{allU (Plus x y)} =  {lub {allU x} {allU y}}

union:: Set ~> Set ~> Set
{union Univ a} = Univ
{union (Times p1 p2) (Times q1 q2)} = Times {union p1 q1} {union p2 q2}
{union (Times a b) (Empty c)} = Times a b
{union (Times a b) Univ} = Univ
{union (Plus p1 p2) (Plus q1 q2)} = Plus {union p1 q1} {union p2 q2}
{union (Plus p1 p2) (Empty c)} = Plus p1 p2
{union (Plus p1 p2) Univ} = Univ
{union (Empty a) x} = x

------------------------------------------------------------
-- Judgements for well-typed patterns and terms

data Prim:: *0 ~> *0 where
  Add :: Prim (Arr Int Total (Arr Int Total Int))
  Sub :: Prim (Arr Int Total (Arr Int Total Int))
  Mul :: Prim (Arr Int Total (Arr Int Total Int))
  Div :: Prim (Arr Int Total (Arr Int Partial Int))

data Pat:: Set ~> *0 ~> Row Tag *0 ~> Row Tag *0 ~> *0 where
  Pvar :: Label a -> Pat Univ t r (RCons a t r)
  Ppair:: Pat s1 a g1 g2 -> Pat s2 b g2 g3 ->
          Pat (Times s1 s2) (a,b) g1 g3
  Pwild:: Pat Univ t r r
  Pnil :: Pat (Plus Univ (Empty `Cons)) [a] r r
  Pcons:: Pat s1 a g1 g2 -> Pat s2 [a] g2 g3 ->
          Pat (Plus (Empty `Nil) (Times s1 s2)) [a] g1 g3

data Exp:: *0 ~> Row Tag *0 ~> Termination ~> *0 where
  Var:: Label a -> Exp t (RCons a t r) Total
  Shift:: Exp t g m -> Exp t (RCons a b g) m
  Const:: Int -> Exp Int g Total
  Oper:: Prim t -> Exp t g Total
  Pair:: Exp x g m -> Exp y g n -> Exp (x,y) g {lub m n}
  App:: Exp (Arr x m b) g n -> Exp x g p -> Exp b g {lub m {lub n p}}
  Abs:: Clause xx (Arr a i b) g1 -> Exp (Arr a {lub {allU xx} i} b) g1 Total
  Nil:: Exp [a] g Total
  Cons:: Exp a g m -> Exp [a] g n -> Exp [a] g {lub m n}
  Undefined:: Exp a g Partial
  Letrec :: Label f ->
            Exp (Arr a Partial b) (RCons f (Arr a Partial b) r) m ->
            Exp c (RCons f (Arr a Partial b) r) n ->
            Exp c r {lub m n}
  Cata :: Exp (Arr a m1 (Arr b m2 b)) r m3 ->
          Exp b r m4 ->
          Exp [a] r m5 ->
          Exp b r {lub m1 {lub m2 {lub m3 {lub m4 m5}}}}

data Clause:: Set ~> *0 ~> Row Tag *0 ~> *0 where
  Last:: (Pat s1 a g1 g2,Exp b g2 m) -> Clause s1 (Arr a m b) g1
  Next:: (Pat s1 a g1 g2,Exp b g2 m) ->
         Clause s (Arr a n b) g1 ->
         Clause {union s1 s} (Arr a {lub m n} b) g1

---------------------------------------------------------------
-- evaluation for well-typed terms

liftOp f = Arr (\ x -> Arr (\ y -> f x y))

evalOp :: Prim t -> t
evalOp Add = liftOp (+)
evalOp Sub = liftOp (-)
evalOp Mul = liftOp (*)
evalOp Div = liftOp div

eval :: Exp t r m -> Rec r -> t
eval (Var a) (RCons b v r) = v
eval (Shift x) (RCons b v r) = eval x r
eval (Const n) r = n
eval (Oper p) r = evalOp p
eval (Pair x y) r = (eval x r, eval y r)
eval (App f x) r = apply (eval f r) (eval x r)
eval (Abs cl) r = Arr (evalClause cl r)
eval Nil r = []
eval (Cons x xs) r = (eval x r):(eval xs r)
eval Undefined r = error "Undefined"
eval (Letrec f fun body) r =
  let r2 = RCons f (eval fun r2) r
  in eval body r2
eval (Cata phi base x) r =
   let phi' = eval phi r
       base' = eval base r
       cata [] = base'
       cata (x:xs) = phi' `apply` x `apply` (cata xs)
    in cata (eval x r)

evalPat :: Pat s t g1 g2 -> t -> Rec g1 -> Maybe (Rec g2)
evalPat (Pvar s) v r = return(RCons s v r)
evalPat (Ppair p q) (x,y) r =
  do { r1 <- evalPat p x r; evalPat q y r1}
evalPat (Pwild {- m -} ) v r = return r
evalPat Pnil [] r = return r
evalPat Pnil (x:xs) r = Nothing
evalPat (Pcons x y) (z:zs) r =
  do { r1 <- evalPat x z r; evalPat y zs r1}
evalPat (Pcons x y) [] r1 = Nothing

evalClause :: Clause s (Arr a m b) g1 -> Rec g1 -> (a -> b)
evalClause (Next (p,e) m) r v =
  case evalPat p v r of
    Nothing -> evalClause m r v
    Just r2 -> eval e r2
evalClause (Last (p,e)) r v =
  case evalPat p v r of
    Nothing -> error "Pattern Match Failure"
    Just r2 -> eval e r2

--------------------------------------------------
-- Some examples

c1 = (Pnil,Const 0)
c2 = (Pcons (Pvar `x) Pwild,Var `x)
c3 = (Pwild, Undefined)
c4 = (Pcons (Pvar `x) (Pcons (Pvar `y) (Pvar `ys)),Shift(Shift(Var `x)))

d1 = Next c1 (Last c2)
d2 = Next c2 (Last c3)
d3 = Last c2
d4 = Last c3
d5 = Next c1 (Last c4)
d6 = Next c2 d5

-- abs :: Label a -> Exp b (RCons (Has a c) d) e -> Exp (Arr c e b) d f
abs x e = Abs(Last (Pvar x,e))

add x y = App (App (Oper Add) x) y
times x y = App (App (Oper Mul) x) y
sub x y = App (App (Oper Sub) x) y

-- let `f = (\ `x -> (1 + ((Sh `f) `x)))
-- in (`f 3)
zz:: Exp Int g Partial
zz =
  Letrec `f (abs `x (App (App (Oper Add) (Const 1))
                         (App (Shift (Var `f)) (Var `x))))
            (App (Var `f) (Const 3))

-- let `length = (\ [] -> 0
--                  (`x:`xs) -> (1 + ((Sh (Sh `length)) `xs)))
-- in `length
length1 :: Exp (Arr [a] Partial Int) b Total
length1 = Letrec `length (Abs (Next (Pnil,Const 0)
                              (Last (Pcons (Pvar `x) (Pvar `xs),
                                     add (Const 1)
                                          (App (Shift(Shift(Var `length)))
                                               (Var `xs))))))
                         (Var `length)

-- \ [] -> 0
--   (`x:_) -> `x
t1x :: Exp (Arr [Int] Total Int) a Total
t1x = Abs d1

-- \ (`x:_) -> `x
--   _ -> undefined
t2x :: Exp (Arr [a] Partial a) b Total
t2x = Abs d2

---- This should fail
##test "Unifier shows too polymorphic"
  t2xBad :: Exp (Arr [a] c a) b Total
  t2xBad = Abs d2

-- \ (`x:_) -> `x
t3x :: Exp (Arr [a] Partial a) b Total
t3x = Abs d3

-- \ _ -> undefined
t4x :: Exp (Arr a Partial b) c Total
t4x = Abs d4

-- \ [] -> 0
--   (`x:(`y:`ys)) -> (Sh (Sh `x))
t5x :: Exp (Arr [Int] Partial Int) a Total
t5x = Abs d5

-- \ (`x:_) -> `x
--   [] -> 0
--   (`x:(`y:`ys)) -> (Sh (Sh `x))
t6x :: Exp (Arr [Int] Total Int) a Total
t6x = Abs d6

-- \ `f -> \ `g -> \ `x -> ((Sh (Sh `f)) ((Sh `g) `x))

-- compose :: Exp (Arr (Arr a b c) d (Arr (Arr e b a) f (Arr e b c))) g h
compose = abs `f (abs `g (abs `x (App (Shift(Shift (Var `f))) (App (Shift (Var `g)) (Var `x)))))

-- \ x -> \ y -> Add y 1
succ = abs `x (abs `y (App (App (Oper Add) (Var `y)) (Const 1)))

length :: Exp (Arr [a] Total Int) g Total
length =
   abs `x (Cata succ
                (Const 0)
                (Var `x))

xs = Cons (Const 1) (Cons (Const 3) (Cons (Const 5) Nil))

-------------------------------------------------
-- printing terms

sp :: Pat a b c d -> String
sp (Pvar s) = show s
sp (Ppair x y) = "("++sp x++","++sp y++")"
sp Pwild = "_"
sp Pnil = "[]"
sp (Pcons x xs) = "("++sp x++":"++sp xs++")"

sc :: Clause a b c -> String
sc (Last(p,e)) = sp p++" -> "++se e
sc (Next (p,e) cs) = sp p++" -> "++se e++"\n--   "++sc cs

se :: Exp a b c -> String
se (Var x) = show x
se (Shift x) = "(Sh "++se x++")"
se (Const n) = show n
se (Pair x y) = "("++se x++","++se y++")"
se (App (App (Oper f) x) y) = "("++se x++so f++se y++")"
se (App x y) = "("++se x++" "++se y++")"
se (Abs cl) = "(\\ "++sc cl++")"
se Nil = "[]"
se (Cons x xs) = "("++se x++":"++se xs++")"
se Undefined = "undefined"
se (Letrec f x y) =
  "-- let "++show f++" = "++se x++"\n   in "++se y++"\n"
se (Oper Add) = "(+)"
se (Oper Sub) = "(-)"
se (Oper Mul) = "(*)"
se (Oper Div) = "div"
se (Cata phi b xs) = "(cata "++se phi++" "++se b++" "++se xs++")"

so :: Prim t -> String
so Add = " + "
so Sub = " - "
so Mul = " * "
so Div = " / "

f x = putStr ("\n"++(se x)++"\n")


QtCore: module updated

QtCore: module updated

Modified:
source/QtCore/QCollator.prg

/*

  Qt5xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 5

  Copyright (C) 2018 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>

*/

/*
  DO NOT EDIT THIS FILE - the content was created using a source code generator
*/

#include "hbclass.ch"

#ifndef QT5XHB_NO_REQUESTS
REQUEST QLOCALE
REQUEST QCOLLATORSORTKEY
#endif

CLASS QCollator

   DATA pointer
   DATA self_destruction INIT .F.

   METHOD new
   METHOD delete
   METHOD swap
   METHOD setLocale
   METHOD locale
   METHOD caseSensitivity
   METHOD setCaseSensitivity
   METHOD setNumericMode
   METHOD numericMode
   METHOD setIgnorePunctuation
   METHOD ignorePunctuation
   METHOD sortKey

   METHOD newFrom
   METHOD newFromObject
   METHOD newFromPointer
   METHOD selfDestruction
   METHOD setSelfDestruction

   DESTRUCTOR destroyObject

END CLASS

PROCEDURE destroyObject () CLASS QCollator
   IF ::self_destruction
      ::delete()
   ENDIF
RETURN

#pragma BEGINDUMP

#include <Qt>

#ifndef __XHARBOUR__
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
#include <QCollator>
#endif
#endif

#include "qt5xhb_common.h"
#include "qt5xhb_macros.h"
#include "qt5xhb_utils.h"

#ifdef __XHARBOUR__
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
#include <QCollator>
#endif
#endif

/*
QCollator(const QLocale &locale = QLocale())
*/
void QCollator_new1 ()
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * o = new QCollator ( ISNIL(1)? QLocale() : *(QLocale *) _qt5xhb_itemGetPtr(1) );
  _qt5xhb_returnNewObject( o, true );
#endif
}

/*
QCollator(const QCollator &)
*/
void QCollator_new2 ()
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * o = new QCollator ( *PQCOLLATOR(1) );
  _qt5xhb_returnNewObject( o, true );
#endif
}

//[1]QCollator(const QLocale &locale = QLocale())
//[2]QCollator(const QCollator &)

HB_FUNC_STATIC( QCOLLATOR_NEW )
{
  if( ISBETWEEN(0,1) && (ISQLOCALE(1)||ISNIL(1)) )
  {
    QCollator_new1();
  }
  else if( ISNUMPAR(1) && ISQCOLLATOR(1) )
  {
    QCollator_new2();
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

HB_FUNC_STATIC( QCOLLATOR_DELETE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    delete obj;
    obj = NULL;
    PHB_ITEM self = hb_stackSelfItem();
    PHB_ITEM ptr = hb_itemPutPtr( NULL, NULL );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
  }

  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
void swap(QCollator &other)
*/
HB_FUNC_STATIC( QCOLLATOR_SWAP )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(1) && ISQCOLLATOR(1) )
    {
      obj->swap ( *PQCOLLATOR(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
void setLocale(const QLocale &locale)
*/
HB_FUNC_STATIC( QCOLLATOR_SETLOCALE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(1) && ISQLOCALE(1) )
    {
      obj->setLocale ( *PQLOCALE(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
QLocale locale() const
*/
HB_FUNC_STATIC( QCOLLATOR_LOCALE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(0) )
    {
      QLocale * ptr = new QLocale( obj->locale () );
      _qt5xhb_createReturnClass ( ptr, "QLOCALE", true );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
#endif
}

/*
Qt::CaseSensitivity caseSensitivity() const
*/
HB_FUNC_STATIC( QCOLLATOR_CASESENSITIVITY )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(0) )
    {
      RENUM( obj->caseSensitivity () );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
#endif
}

/*
void setCaseSensitivity(Qt::CaseSensitivity cs)
*/
HB_FUNC_STATIC( QCOLLATOR_SETCASESENSITIVITY )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(1) && ISNUM(1) )
    {
      obj->setCaseSensitivity ( (Qt::CaseSensitivity) hb_parni(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
void setNumericMode(bool on)
*/
HB_FUNC_STATIC( QCOLLATOR_SETNUMERICMODE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(1) && ISLOG(1) )
    {
      obj->setNumericMode ( PBOOL(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
bool numericMode() const
*/
HB_FUNC_STATIC( QCOLLATOR_NUMERICMODE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(0) )
    {
      RBOOL( obj->numericMode () );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
#endif
}

/*
void setIgnorePunctuation(bool on)
*/
HB_FUNC_STATIC( QCOLLATOR_SETIGNOREPUNCTUATION )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(1) && ISLOG(1) )
    {
      obj->setIgnorePunctuation ( PBOOL(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
bool ignorePunctuation() const
*/
HB_FUNC_STATIC( QCOLLATOR_IGNOREPUNCTUATION )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(0) )
    {
      RBOOL( obj->ignorePunctuation () );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
#endif
}

/*
QCollatorSortKey sortKey(const QString &string) const
*/
HB_FUNC_STATIC( QCOLLATOR_SORTKEY )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(1) && ISCHAR(1) )
    {
      QCollatorSortKey * ptr = new QCollatorSortKey( obj->sortKey ( PQSTRING(1) ) );
      _qt5xhb_createReturnClass ( ptr, "QCOLLATORSORTKEY", true );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
#endif
}

HB_FUNC_STATIC( QCOLLATOR_NEWFROM )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISOBJECT(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else if( hb_pcount() == 1 && ISPOINTER(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_param(1, HB_IT_POINTER ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }

  hb_itemReturn( self );
}

HB_FUNC_STATIC( QCOLLATOR_NEWFROMOBJECT )
{
  HB_FUNC_EXEC( QCOLLATOR_NEWFROM );
}

HB_FUNC_STATIC( QCOLLATOR_NEWFROMPOINTER )
{
  HB_FUNC_EXEC( QCOLLATOR_NEWFROM );
}

HB_FUNC_STATIC( QCOLLATOR_SELFDESTRUCTION )
{
  hb_retl( (bool) hb_itemGetL( hb_objSendMsg( hb_stackSelfItem(), "SELF_DESTRUCTION", 0 ) ) );
}

HB_FUNC_STATIC( QCOLLATOR_SETSELFDESTRUCTION )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISLOG(1) )
  {
    PHB_ITEM des = hb_itemPutL( NULL, hb_parl(1) );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }

  hb_itemReturn( self );
}

#pragma ENDDUMP

/*

  Qt5xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 5

  Copyright (C) 2018 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>

*/

/*
  DO NOT EDIT THIS FILE - the content was created using a source code generator
*/

#include "hbclass.ch"

#ifndef QT5XHB_NO_REQUESTS
REQUEST QLOCALE
REQUEST QCOLLATORSORTKEY
#endif

CLASS QCollator

   DATA pointer
   DATA self_destruction INIT .F.

   METHOD new
   METHOD delete
   METHOD swap
   METHOD setLocale
   METHOD locale
   METHOD caseSensitivity
   METHOD setCaseSensitivity
   METHOD setNumericMode
   METHOD numericMode
   METHOD setIgnorePunctuation
   METHOD ignorePunctuation
   METHOD sortKey

   METHOD newFrom
   METHOD newFromObject
   METHOD newFromPointer
   METHOD selfDestruction
   METHOD setSelfDestruction

   DESTRUCTOR destroyObject

END CLASS

PROCEDURE destroyObject () CLASS QCollator
   IF ::self_destruction
      ::delete()
   ENDIF
RETURN

#pragma BEGINDUMP

#include <Qt>

#ifndef __XHARBOUR__
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
#include <QCollator>
#endif
#endif

#include "qt5xhb_common.h"
#include "qt5xhb_macros.h"
#include "qt5xhb_utils.h"

#ifdef __XHARBOUR__
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
#include <QCollator>
#endif
#endif

/*
QCollator(const QLocale &locale = QLocale())
*/
void QCollator_new1 ()
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * o = new QCollator ( ISNIL(1)? QLocale() : *(QLocale *) _qt5xhb_itemGetPtr(1) );
  _qt5xhb_returnNewObject( o, true );
#endif
}

/*
QCollator(const QCollator &)
*/
void QCollator_new2 ()
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * o = new QCollator ( *PQCOLLATOR(1) );
  _qt5xhb_returnNewObject( o, true );
#endif
}

//[1]QCollator(const QLocale &locale = QLocale())
//[2]QCollator(const QCollator &)

HB_FUNC_STATIC( QCOLLATOR_NEW )
{
  if( ISBETWEEN(0,1) && (ISQLOCALE(1)||ISNIL(1)) )
  {
    QCollator_new1();
  }
  else if( ISNUMPAR(1) && ISQCOLLATOR(1) )
  {
    QCollator_new2();
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

HB_FUNC_STATIC( QCOLLATOR_DELETE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    delete obj;
    obj = NULL;
    PHB_ITEM self = hb_stackSelfItem();
    PHB_ITEM ptr = hb_itemPutPtr( NULL, NULL );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
  }

  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
void swap(QCollator &other)
*/
HB_FUNC_STATIC( QCOLLATOR_SWAP )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(1) && ISQCOLLATOR(1) )
    {
      obj->swap ( *PQCOLLATOR(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
void setLocale(const QLocale &locale)
*/
HB_FUNC_STATIC( QCOLLATOR_SETLOCALE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(1) && ISQLOCALE(1) )
    {
      obj->setLocale ( *PQLOCALE(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
QLocale locale() const
*/
HB_FUNC_STATIC( QCOLLATOR_LOCALE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(0) )
    {
      QLocale * ptr = new QLocale( obj->locale () );
      _qt5xhb_createReturnClass ( ptr, "QLOCALE", true );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
#endif
}

/*
Qt::CaseSensitivity caseSensitivity() const
*/
HB_FUNC_STATIC( QCOLLATOR_CASESENSITIVITY )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(0) )
    {
      RENUM( obj->caseSensitivity () );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
#endif
}

/*
void setCaseSensitivity(Qt::CaseSensitivity cs)
*/
HB_FUNC_STATIC( QCOLLATOR_SETCASESENSITIVITY )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(1) && ISNUM(1) )
    {
      obj->setCaseSensitivity ( (Qt::CaseSensitivity) hb_parni(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
void setNumericMode(bool on)
*/
HB_FUNC_STATIC( QCOLLATOR_SETNUMERICMODE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(1) && ISLOG(1) )
    {
      obj->setNumericMode ( PBOOL(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
bool numericMode() const
*/
HB_FUNC_STATIC( QCOLLATOR_NUMERICMODE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(0) )
    {
      RBOOL( obj->numericMode () );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
#endif
}

/*
void setIgnorePunctuation(bool on)
*/
HB_FUNC_STATIC( QCOLLATOR_SETIGNOREPUNCTUATION )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(1) && ISLOG(1) )
    {
      obj->setIgnorePunctuation ( PBOOL(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
bool ignorePunctuation() const
*/

/*
QCollatorSortKey sortKey(const QString &string) const
*/
HB_FUNC_STATIC( QCOLLATOR_SORTKEY )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
  QCollator * obj = (QCollator *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(1) && ISCHAR(1) )
    {
      QCollatorSortKey * ptr = new QCollatorSortKey( obj->sortKey ( PQSTRING(1) ) );
      _qt5xhb_createReturnClass ( ptr, "QCOLLATORSORTKEY", true );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
#endif
}

HB_FUNC_STATIC( QCOLLATOR_NEWFROM )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISOBJECT(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else if( hb_pcount() == 1 && ISPOINTER(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_param(1, HB_IT_POINTER ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }

  hb_itemReturn( self );
}

HB_FUNC_STATIC( QCOLLATOR_NEWFROMOBJECT )
{
  HB_FUNC_EXEC( QCOLLATOR_NEWFROM );
}

HB_FUNC_STATIC( QCOLLATOR_NEWFROMPOINTER )
{
  HB_FUNC_EXEC( QCOLLATOR_NEWFROM );
}

HB_FUNC_STATIC( QCOLLATOR_SELFDESTRUCTION )
{
  hb_retl( (bool) hb_itemGetL( hb_objSendMsg( hb_stackSelfItem(), "SELF_DESTRUCTION", 0 ) ) );
}

HB_FUNC_STATIC( QCOLLATOR_SETSELFDESTRUCTION )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISLOG(1) )
  {
    PHB_ITEM des = hb_itemPutL( NULL, hb_parl(1) );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }

  hb_itemReturn( self );
}

#pragma ENDDUMP


Added more test code.

Added more test code.

   *comment with spaces
#DEFINE cantbewrong
#DEFINE SPACE CHR
#IFDEF cantbewrong
#IF FILE ( 'test.h' )
   ***comment***
   # include  test.h
   # include  'test.h'
   # include  'test' + '.h'
   STORE 5 to  x && set x to 5
#ELSE
#ENDIF
   x = 'test' + CHR(13) + CHR(10)
   x = space(5)
   x = '' + CHR(13) + CHR(10)
#ELSE
_SCREEN.LOGO.TOP = (_SCREEN.HEIGHT-_SCREEN.LOGO.HEIGHT)/2-3

WAIT WINDOW space(3) + 'please wait' + CHR(32) NOWAIT TIMEOUT 1.3
#ENDIF

ON ERROR
ON ERROR DO test
?LEFT('Hello, World', 5)
WAIT WINDOW space(3) + 'please wait' + CHR(32) NOWAIT TIMEOUT 1.3
md test - test
MD test+test
md (test+test)
*com;
ment
NOTE note;
comment
x = 5*2**3**4
x = (1+2)*3
None = .nUlL.
Bool = .Y.
somedate = { / / }

if x > 5
else
   ?'hello'
   ?'goodbye'
ENDif

if x > 5
**do nothing
else
endif

delete file test . h
delete file test.h
delete file x
delete file (x)
delete file '' + x

_screen.refresh
test.prg()
test.prg(1)

if .f.
else
DO CASE
   CASE X == 1 && case 1
      do case
         case x == 1

      endcase
      X = 2
   CASE X == 2 && case 2
      X = 3
   CASE X == 2 && case 2 again
      X = 3
   CASE X == 2
      X = 3
   CASE X == 2
      X = 3
   CASE X == 2
      X = 3
ENDCASE
endif

do case
endcase

do case
endcase &&empty case end with comment

t=u(v(w(x(y(z)))))

*** CREATE REPORT TABLE
CREATE TABLE REPORT FREE (NAME C(50), ST C(2), QUANTITY N(5, 0), RECEIVED L(1))
USE REPORT IN 0 SHARED
SELECT REPORT
APPEND BLANK

REPLACE REPORT.NAME WITH 'Michael'
REPLACE REPORT.ST WITH 'IA'
REPLACE REPORT.QUANTITY WITH 4
REPLACE REPORT.RECEIVED WITH .F.

GO TOP

FOR X = 1 TO REPORT.QUANITY
    SET PRINTER TO ALLTRIM('printer')
    REPORT FORM TEST.FRX TO PRINTER NOCONSOLE
    SET PRINTER TO
ENDFOR

FOR X = 1 TO REPORT.QUANITY
ENDFOR

tablename = 'REPORT'

USE (tablename) IN 0 SHARED

IF USED('REPORT')
   SELECT REPORT
   USE IN REPORT
ENDIF

DO test
DO test in test

IF FILE('DBFTABLE.DBF')
   USE DBFTABLE IN 0 SHARED
   SELECT DBFTABLE
   COPY STRUCTURE TO 'DBFTEMP.DBF'
   IF USED('DBFTABLE')
      SELECT DBFTABLE
      USE IN DBFTABLE
   ENDIF
   IF USED('DBFTEMP')
      SELECT DBFTEMP
      USE IN DBFTEMP
   ENDIF
ENDIF

RELEASE ALL
RELEASE test1
RELEASE test1, test2, test3

FUNCTION test
   parameters a, b
   ?a, b

FUNCTION REPLACE_TEST(TABLENAME, FIELD_VAL)
   IF FILE(TABLE_NAME + '.DBF')
      USE (TABLENAME) IN 0 SHARED
      SELECT (TABLENAME)
      SELECT('TABLENAME')
      REPLACE ALL TEST WITH .T. FOR FIELD1 = FIELDVAL
      GO TOP
      SKIP -3
      SKIP 1
      GO BOTTOM
      GO 15
      DELETE NEXT 1
      DELETE NEXT 10
      DELETE NEXT (THREE)
      USE IN SELECT(TABLENAME)
      USE IN SELECT('tablename')
      USE IN TABLENAME
      USE IN (TABLENAME)
      USE IN 'TABLENAME'
   ENDIF
   RETURN

DEFINE CLASS test as custom
   x = 3 && x is a thing in this class
   procedure init
      parameters initx, inity
      x = initx

   function athing(test)
      return this.x
   endfunc
ENDDEFINE

DEFINE CLASS test2 as form
   add object test as t with prop = 'hello'
   add object cbox as combobox
   x = 3
ENDDEFINE

   *comment with spaces
#DEFINE cantbewrong
#DEFINE SPACE CHR
#IFDEF cantbewrong
#IF FILE ( 'test.h' )
   ***comment***
   # include  test.h
   # include  'test.h'
   # include  'test' + '.h'
   STORE 5 to  x && set x to 5
#ELSE
#ENDIF
   x = 'test' + CHR(13) + CHR(10)
   x = space(5)
   x = '' + CHR(13) + CHR(10)
#ELSE
_SCREEN.LOGO.TOP = (_SCREEN.HEIGHT-_SCREEN.LOGO.HEIGHT)/2-3

WAIT WINDOW space(3) + 'please wait' + CHR(32) NOWAIT TIMEOUT 1.3
#ENDIF

?LEFT('Hello, World', 5)
WAIT WINDOW space(3) + 'please wait' + CHR(32) NOWAIT TIMEOUT 1.3
md test - test
MD test+test
md (test+test)
*com;
ment
NOTE note;
comment
x = 5*2**3**4
x = (1+2)*3
None = .nUlL.
Bool = .Y.
somedate = { / / }

if x > 5
else
   ?'hello'
   ?'goodbye'
ENDif

if x > 5
**do nothing
else
endif

delete file test . h
delete file test.h
delete file x
delete file (x)
delete file '' + x

_screen.refresh
test.prg()
test.prg(1)

if .f.
else
DO CASE
   CASE X == 1 && case 1
      do case
         case x == 1

      endcase
      X = 2
   CASE X == 2 && case 2
      X = 3
   CASE X == 2 && case 2 again
      X = 3
   CASE X == 2
      X = 3
   CASE X == 2
      X = 3
   CASE X == 2
      X = 3
ENDCASE
endif

do case
endcase

do case
endcase &&empty case end with comment

t=u(v(w(x(y(z)))))

*** CREATE REPORT TABLE
CREATE TABLE REPORT FREE (NAME C(50), ST C(2), QUANTITY N(5, 0), RECEIVED L(1))
USE REPORT IN 0 SHARED
SELECT REPORT
APPEND BLANK

REPLACE REPORT.NAME WITH 'Michael'
REPLACE REPORT.ST WITH 'IA'
REPLACE REPORT.QUANTITY WITH 4
REPLACE REPORT.RECEIVED WITH .F.

GO TOP

FOR X = 1 TO REPORT.QUANITY
    SET PRINTER TO ALLTRIM('printer')
    REPORT FORM TEST.FRX TO PRINTER NOCONSOLE
    SET PRINTER TO
ENDFOR

FOR X = 1 TO REPORT.QUANITY
ENDFOR

tablename = 'REPORT'

USE (tablename) IN 0 SHARED

IF USED('REPORT')
   SELECT REPORT
   USE IN REPORT
ENDIF

DO test in test

IF FILE('DBFTABLE.DBF')
   USE DBFTABLE IN 0 SHARED
   SELECT DBFTABLE
   COPY STRUCTURE TO 'DBFTEMP.DBF'
   IF USED('DBFTABLE')
      SELECT DBFTABLE
      USE IN DBFTABLE
   ENDIF
   IF USED('DBFTEMP')
      SELECT DBFTEMP
      USE IN DBFTEMP
   ENDIF
ENDIF

FUNCTION test
   parameters a, b
   ?a, b

FUNCTION REPLACE_TEST(TABLENAME, FIELD_VAL)
   IF FILE(TABLE_NAME + '.DBF')
      USE (TABLENAME) IN 0 SHARED
      SELECT (TABLENAME)
      SELECT('TABLENAME')
      REPLACE ALL TEST WITH .T. FOR FIELD1 = FIELDVAL
      GO TOP
      SKIP -3
      GO BOTTOM
      GO 15
      USE IN SELECT(TABLENAME)
      USE IN SELECT('tablename')
      USE IN TABLENAME
      USE IN (TABLENAME)
      USE IN 'TABLENAME'
   ENDIF
   RETURN

DEFINE CLASS test as custom
   x = 3 && x is a thing in this class
   procedure init
      parameters initx, inity
      x = initx

   function athing(test)
      return this.x
   endfunc
ENDDEFINE

DEFINE CLASS test2 as form
   add object test as t with prop = 'hello'
   add object cbox as combobox
   x = 3
ENDDEFINE


[Runtime tests] Added several Str() tests

//
// Copyright (c) XSharp B.V.  All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//
USING System
USING System.Collections.Generic
USING System.Linq
USING System.Text
using XUnit
using System.Globalization

BEGIN NAMESPACE XSharp.VO.Tests

	class TransFormTests

		[Fact, Trait("Category", "TransForm")];
		method LogicalTest() as void
			// with @R other chars are appended, but only a single YN or TF flag is written. Other positions become a space
			Assert.Equal("Y", TransForm(true, "Y"))
			Assert.Equal("N", TransForm(false, "Y"))
			Assert.Equal("T", TransForm(true, "L"))
			Assert.Equal("F", TransForm(false, "L"))
			Assert.Equal("T x", TransForm(true, "@R L x"))
			Assert.Equal("F x", TransForm(false, "@R L x"))
			Assert.Equal("Y x", TransForm(true, "@R YYx"))
			Assert.Equal("N x", TransForm(FALSE, "@R YYx"))
			SetNatDLL("French.DLL")
			Assert.Equal("O", TransForm(true, "Y"))
			Assert.Equal("N", TransForm(false, "Y"))
			Assert.Equal("V", TransForm(true, "L"))
			Assert.Equal("F", TransForm(false, "L"))
			Assert.Equal("V x", TransForm(true, "@R L x"))
			Assert.Equal("F x", TransForm(false, "@R L x"))
			Assert.Equal("O x", TransForm(true, "@R YYx"))
			Assert.Equal("N x", TransForm(false, "@R YYx"))

		[Fact, Trait("Category", "TransForm")];
		method DateTest() as void
			// with @R other chars are appended, but only a single YN or TF flag is written. Other positions become a space
			Assert.Equal("10/12/2010", TransForm(2010.12.10,"@E"))
			Assert.Equal("20/11/2010", TransForm(2010.11.20,"@E"))
			SetDateFormat("dd-mm-yyyy")
			Assert.Equal("20-11-2010", TransForm(2010.11.20,"@D"))
			SetDateFormat("dd-mm-yy")
			Assert.Equal("20-11-10", TransForm(2010.11.20,"@D"))

		[Fact, Trait("Category", "TransForm")];
		method StringTest() as void
			Assert.Equal("ABC", Transform("abc", "@!"))
			Assert.Equal("AbC", Transform("abc", "!a!"))
			Assert.Equal("1234 AB", Transform("1234ab", "@R! 9999 AA"))
			Assert.Equal("1234 AB", Transform("1234ab", "@R 9999 !!"))

		[Fact, Trait("Category", "TransForm")];
		METHOD LongTest() AS VOID
			SetDecimalSep('.')
			SetThousandSep(',')
			Assert.Equal("  1", Transform(1, "999"))
			Assert.Equal("123", Transform(123, "###"))
			Assert.Equal("**", Transform(123, "##"))
			Assert.Equal("**", Transform(123, "99"))
			Assert.Equal("(1)", Transform(-1, "@( 99"))
			Assert.Equal("(-1)", Transform(-1, "@( 999"))
			Assert.Equal("( -1)", Transform(-1, "@( 9999"))
			Assert.Equal("(-1)", Transform(-1, "@) 9999"))
			Assert.Equal(" (-1)", Transform(-1, "@) 99999"))
			Assert.Equal("   ", Transform(0, "@Z 999"))
			Assert.Equal(" -1 DB", Transform(-1, "@X 999"))
			Assert.Equal(" -1 DB", Transform(-1, "@XC 999"))
			Assert.Equal("  1 CR", Transform(1, "@XC 999"))
			Assert.Equal("  1 CR", Transform(1, "@C 999"))
			Assert.Equal("  0", Transform(0, "@C 999"))
			Assert.Equal("1,234", Transform(1234, "9,999"))
			SetDecimalSep(',')
			SetThousandSep('.')
			Assert.Equal("1.234", Transform(1234, "9,999"))

		[Fact, Trait("Category", "TransForm")];
		method FLoatTest() as void
			SetDecimalSep('.')
			SetThousandSep(',')
			Assert.Equal("1.23", Transform(1.23, "9.99"))
			Assert.Equal("1,23", Transform(1.23, "@E 9.99"))
			Assert.Equal("*.**", Transform(12.34, "9.99"))

// some new failing tests:
	[Fact, Trait("Category", "TransForm")];
	METHOD IntLiteralTest() AS VOID
		LOCAL dec AS dword
		LOCAL thou AS DWORD

		dec := SetDecimalSep(Asc(","))
		thou := SetThousandSep(Asc("."))
		Assert.Equal(" 12.345,00" , Transform(12345.0, "999,999.99"))
		// this fails:
		Assert.Equal(" 12.345,00" , Transform(12345, "999,999.99"))

		SetDecimalSep(Asc("."))
		SetThousandSep(Asc(","))
		Assert.Equal(" 12,345.00" , Transform(12345.0, "999,999.99"))
		Assert.Equal(" 12,345.00" , Transform(12345, "999,999.99"))

		SetDecimalSep(dec)
		SetThousandSep(thou)
	RETURN

// Tests that need to be moved in separate files in VO.Tests:
	[Fact, Trait("Category", "StringEq")];
	METHOD StringEquality() AS VOID
		LOCAL c1,c2 AS STRING
		LOCAL u1,u2 AS USUAL
		local exact as LOGIC
		u1 := c1 := "TESTLONG"
		u2 := c2 := "TEST"
		exact := SetExact( FALSE )

		Assert.Equal(true, c1 = c2)
		Assert.Equal(true, c1 != c2)

		Assert.Equal(true, u1 = u2)
		Assert.Equal(false, u1 != u2)

		SetExact( exact )
	RETURN

	[Fact, Trait("Category", "Str")];
	METHOD StrTests() AS VOID
		local exact,thou,digit,decimal,fixed_,digitfixed as usual
		exact := SetDecimalSep(Asc("."))
		thou := SetThousandSep(Asc(","))
		digit := SetDigit(6)
		decimal := SetDecimal(3)
		fixed_ := SetFixed(FALSE)
		digitfixed := SetDigitFixed(FALSE)

		Assert.Equal( "     1.2"			, Str(1.2) )
		Assert.Equal( "    12.3"			, Str(12.3) )
		Assert.Equal( "    12.34"			, Str(12.34) )
		Assert.Equal( "   123.456"			, Str(123.456) )
		Assert.Equal( "  1234.567"			, Str(1234.567) )
		Assert.Equal( "  1234.5678"			, Str(1234.5678) )
		Assert.Equal( "  1234.5679012345"	, Str(1234.5679012345) )
		Assert.Equal( "123456.78901234567"	, Str(123456.78901234567) )
		Assert.Equal( "999999" , Str(999999) )
		Assert.Equal( "******" , Str(1000000) )

		SetDecimalSep(exact)
		SetThousandSep(thou)
		SetDigit(digit)
		SetDecimal(decimal)
		SetFixed(fixed_)
		SetDigitFixed(digitfixed)
	RETURN

	[Fact, Trait("Category", "Str")];
	METHOD Str_With_SetFixed_TRUE() AS VOID

	   SetDecimalSep(Asc("."))
	   SetThousandSep(Asc(","))
	   SetDecimal(3)
	   SetDigit(12)

	   SetFixed(TRUE)
	   SetDigitFixed(TRUE)

	   Assert.Equal( Str(12.34)            		, "          12.340")
	   Assert.Equal( Str1(12.34)          		, "          12.340")
	   Assert.Equal( Str(123.456)         		, "         123.456")
	   Assert.Equal( Str1(123.456)       		, "         123.456")
	   Assert.Equal( Str(1230.4567)         	, "        1230.457")
	   Assert.Equal( Str1(1230.4567)        	, "        1230.457")
	   Assert.Equal( Str(100000001234.4567)		, "100000001234.457")
	   Assert.Equal( Str1(100000001234.4567)	, "100000001234.457")
	   Assert.Equal( Str(1000000001234.4567)	, "****************")
	   Assert.Equal( Str1(1000000001234.4567)	, "****************")
	   Assert.Equal( Str(12.3)              	, "          12.300")
	   Assert.Equal( Str1(12.3)            		, "          12.300")
	   Assert.Equal( Str(12.34567)        	 	, "          12.346")
	   Assert.Equal( Str1(12.34567)        		, "          12.346")
	   Assert.Equal( Str(12.34 , 10, 2)    		, "     12.34")
	   Assert.Equal( Str(12.34 , 5, 2)     		, "12.34")
	   Assert.Equal( Str(12.34 , 4, 2)     		, "12.3")
	   Assert.Equal( Str(12.34 , 4, 1)     		, "12.3")
	   Assert.Equal( Str(12.34 , 2, 1)     		, "**")
	   Assert.Equal( Str3(12.34 , 10, 2)   		, "     12.34")
	   Assert.Equal( Str3(12.34 , 5, 2)    		, "12.34")
	   Assert.Equal( Str3(12.34 , 4, 2)     	, "12.3")
	   Assert.Equal( Str3(12.34 , 4, 1)     	, "12.3")
	   Assert.Equal( Str3(12.34 , 2, 1)    		, "**")
	   Assert.Equal( Str(-12.34)            	, "         -12.340")
	   Assert.Equal( Str1(-12.34)           	, "         -12.340")
	   Assert.Equal( Str(-12.3456)         		, "         -12.346")
	   Assert.Equal( Str1(-12.3456)         	, "         -12.346")
	   Assert.Equal( Str(-12.34 , 10, 2)    	, "    -12.34")
	   Assert.Equal( Str(-12.34 , 5, 2)     	, "-12.3")	 //VO wrong: -2.34
	   Assert.Equal( Str(-12.34 , 4, 2)     	, "-12.")
	   Assert.Equal( Str(-12.34 , 4, 1)     	, " -12")    //VO wrong: -2.3
	   Assert.Equal( Str(-12.34 , 2, 1)     	, "**")
	RETURN

	[Fact, Trait("Category", "Str")];
	METHOD Str_With_SetFixed_FALSE() AS VOID

	   SetDecimalSep(Asc("."))
	   SetThousandSep(Asc(","))
	   SetDecimal(3)
	   SetDigit(12)

	   SetFixed(FALSE)
	   SetDigitFixed(FALSE)

	   Assert.Equal( Str(12.34)            		, "          12.34")
	   Assert.Equal( Str1(12.34)          		, "          12.34")
	   Assert.Equal( Str(123.456)         		, "         123.456")
	   Assert.Equal( Str1(123.456)				, "         123.456")
	   Assert.Equal( Str(1230.4567)         	, "        1230.4567")
	   Assert.Equal( Str1(1230.4567)        	, "        1230.4567")
	   Assert.Equal( Str(100000001234.4567)		, "100000001234.4567")
	   Assert.Equal( Str1(100000001234.4567)	, "100000001234.4567")
	   Assert.Equal( Str(1000000001234.4567)	, "*****************")
	   Assert.Equal( Str1(1000000001234.4567)	, "*****************")
	   Assert.Equal( Str(12.3)              	, "          12.3")
	   Assert.Equal( Str1(12.3)            		, "          12.3")
	   Assert.Equal( Str(12.34567)         		, "          12.34567")
	   Assert.Equal( Str1(12.34567)        		, "          12.34567")
	   Assert.Equal( Str(12.34 , 10, 2)    		, "     12.34")
	   Assert.Equal( Str(12.34 , 5, 2)     		, "12.34")
	   Assert.Equal( Str(12.34 , 4, 2)     		, "12.3")
	   Assert.Equal( Str(12.34 , 4, 1)     		, "12.3")
	   Assert.Equal( Str(12.34 , 2, 1)     		, "**")
	   Assert.Equal( Str3(12.34 , 10, 2)   		, "     12.34")
	   Assert.Equal( Str3(12.34 , 5, 2)    		, "12.34")
	   Assert.Equal( Str3(12.34 , 4, 2)     	, "12.3")
	   Assert.Equal( Str3(12.34 , 4, 1)     	, "12.3")
	   Assert.Equal( Str3(12.34 , 2, 1)    		, "**")
	   Assert.Equal( Str(-12.34)            	, "         -12.34")
	   Assert.Equal( Str1(-12.34)           	, "         -12.34")
	   Assert.Equal( Str(-12.3456)         		, "         -12.3456")
	   Assert.Equal( Str1(-12.3456)         	, "         -12.3456")
	   Assert.Equal( Str(-12.34 , 10, 2)    	, "    -12.34")
	   Assert.Equal( Str(-12.34 , 5, 2)     	, "-12.3")	 //VO: -2.34
	   Assert.Equal( Str(-12.34 , 4, 2)     	, "-12.")
	   Assert.Equal( Str(-12.34 , 4, 1)     	, " -12")    //VO: -2.3
	   Assert.Equal( Str(-12.34 , 2, 1)     	, "**")

	[Fact, Trait("Category", "Val")];
	METHOD ValTests() AS VOID
		Assert.Equal(123, (int) Val("123") )
		Assert.Equal(123.456, (real8) Val("123.456") )

		Assert.Equal(0, (int) Val("") )

		Assert.Equal(0, (int) Val("abc") )
		Assert.Equal(123, (int) Val("123abc") )
		Assert.Equal(123, (int) Val("123abc456") )
		Assert.Equal(123, (int) Val("123abc456.789") )
		Assert.Equal(0, (INT) Val("abc123456.789") )
		Assert.Equal(255, (INT) Val("0xFF") )
		Assert.Equal(0xFFFF, (INT) Val("0xFFFF") )
		Assert.Equal(4294967295, (INT64) Val("0xFFFFFFFF") )
		Assert.Equal(11, (INT) Val("11L11") )
		Assert.Equal(1.000, (REAL8) Val("1,000.1") )
		Assert.Equal(1.001, (real8) Val("1,001.1") )
	RETURN

	[Fact, Trait("Category", "SplitPath")];
	METHOD SplitPathTests() AS VOID
		LOCAL cDrive := "",cDir := "",cFile := "",cExt := "" AS STRING
		SplitPath("C:\folder\file.ext" ,  cDrive , cDir , cFile , cExt)

		Assert.Equal("C:" , cDrive)
		Assert.Equal("\folder\" , cDir)

		Assert.Equal("file" , cFile)
		Assert.Equal(".ext" , cExt)
	RETURN

	[Fact, Trait("Category", "SplitPathVO")];
	METHOD SplitPathVO() AS VOID
		LOCAL cPath ,cDrive ,cDir ,cFile ,cExt AS STRING
		LOCAL pszDrive, pszDir AS PSZ
		LOCAL pszFile, pszExt AS PSZ

		cPath := "C:\testfolder\testfile.prg"

		pszDrive := MemAlloc(2+1)
		pszDir   := MemAlloc(255+1)
		pszFile  := MemAlloc(255+1)
		pszExt   := MemAlloc(7+1)

		SplitPath(String2Psz(cPath), pszDrive, pszDir,        ;
			 pszFile, pszExt)

		cDrive := Psz2String(pszDrive)
		cDir   := Psz2String(pszDir)
		cFile  := Psz2String(pszFile)
		cExt   := Psz2String(pszExt)

		MemFree(pszDrive)
		MemFree(pszDir)
		MemFree(pszFile)
		MemFree(pszExt)

		Assert.Equal("\testfolder\" , cDir)
		Assert.Equal("\testfolder\" , cDir)
		Assert.Equal("testfile" , cFile)
		Assert.Equal(".prg" , cExt)
	RETURN

	end class
end NAMESPACE

//
// Copyright (c) XSharp B.V.  All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//
USING System
USING System.Collections.Generic
USING System.Linq
USING System.Text
using XUnit
using System.Globalization

BEGIN NAMESPACE XSharp.VO.Tests

	class TransFormTests

		[Fact, Trait("Category", "TransForm")];
		method LogicalTest() as void
			// with @R other chars are appended, but only a single YN or TF flag is written. Other positions become a space
			Assert.Equal("Y", TransForm(true, "Y"))
			Assert.Equal("N", TransForm(false, "Y"))
			Assert.Equal("T", TransForm(true, "L"))
			Assert.Equal("F", TransForm(false, "L"))
			Assert.Equal("T x", TransForm(true, "@R L x"))
			Assert.Equal("F x", TransForm(false, "@R L x"))
			Assert.Equal("Y x", TransForm(true, "@R YYx"))
			Assert.Equal("N x", TransForm(FALSE, "@R YYx"))
			SetNatDLL("French.DLL")
			Assert.Equal("O", TransForm(true, "Y"))
			Assert.Equal("N", TransForm(false, "Y"))
			Assert.Equal("V", TransForm(true, "L"))
			Assert.Equal("F", TransForm(false, "L"))
			Assert.Equal("V x", TransForm(true, "@R L x"))
			Assert.Equal("F x", TransForm(false, "@R L x"))
			Assert.Equal("O x", TransForm(true, "@R YYx"))
			Assert.Equal("N x", TransForm(false, "@R YYx"))

		[Fact, Trait("Category", "TransForm")];
		method DateTest() as void
			// with @R other chars are appended, but only a single YN or TF flag is written. Other positions become a space
			Assert.Equal("10/12/2010", TransForm(2010.12.10,"@E"))
			Assert.Equal("20/11/2010", TransForm(2010.11.20,"@E"))
			SetDateFormat("dd-mm-yyyy")
			Assert.Equal("20-11-2010", TransForm(2010.11.20,"@D"))
			SetDateFormat("dd-mm-yy")
			Assert.Equal("20-11-10", TransForm(2010.11.20,"@D"))

		[Fact, Trait("Category", "TransForm")];
		method StringTest() as void
			Assert.Equal("ABC", Transform("abc", "@!"))
			Assert.Equal("AbC", Transform("abc", "!a!"))
			Assert.Equal("1234 AB", Transform("1234ab", "@R! 9999 AA"))
			Assert.Equal("1234 AB", Transform("1234ab", "@R 9999 !!"))

		[Fact, Trait("Category", "TransForm")];
		METHOD LongTest() AS VOID
			SetDecimalSep('.')
			SetThousandSep(',')
			Assert.Equal("  1", Transform(1, "999"))
			Assert.Equal("123", Transform(123, "###"))
			Assert.Equal("**", Transform(123, "##"))
			Assert.Equal("**", Transform(123, "99"))
			Assert.Equal("(1)", Transform(-1, "@( 99"))
			Assert.Equal("(-1)", Transform(-1, "@( 999"))
			Assert.Equal("( -1)", Transform(-1, "@( 9999"))
			Assert.Equal("(-1)", Transform(-1, "@) 9999"))
			Assert.Equal(" (-1)", Transform(-1, "@) 99999"))
			Assert.Equal("   ", Transform(0, "@Z 999"))
			Assert.Equal(" -1 DB", Transform(-1, "@X 999"))
			Assert.Equal(" -1 DB", Transform(-1, "@XC 999"))
			Assert.Equal("  1 CR", Transform(1, "@XC 999"))
			Assert.Equal("  1 CR", Transform(1, "@C 999"))
			Assert.Equal("  0", Transform(0, "@C 999"))
			Assert.Equal("1,234", Transform(1234, "9,999"))
			SetDecimalSep(',')
			SetThousandSep('.')
			Assert.Equal("1.234", Transform(1234, "9,999"))

		[Fact, Trait("Category", "TransForm")];
		method FLoatTest() as void
			SetDecimalSep('.')
			SetThousandSep(',')
			Assert.Equal("1.23", Transform(1.23, "9.99"))
			Assert.Equal("1,23", Transform(1.23, "@E 9.99"))
			Assert.Equal("*.**", Transform(12.34, "9.99"))

// some new failing tests:
	[Fact, Trait("Category", "TransForm")];
	METHOD IntLiteralTest() AS VOID
		LOCAL dec AS dword
		LOCAL thou AS DWORD

		dec := SetDecimalSep(Asc(","))
		thou := SetThousandSep(Asc("."))
		Assert.Equal(" 12.345,00" , Transform(12345.0, "999,999.99"))
		// this fails:
		Assert.Equal(" 12.345,00" , Transform(12345, "999,999.99"))

		SetDecimalSep(Asc("."))
		SetThousandSep(Asc(","))
		Assert.Equal(" 12,345.00" , Transform(12345.0, "999,999.99"))
		Assert.Equal(" 12,345.00" , Transform(12345, "999,999.99"))

		SetDecimalSep(dec)
		SetThousandSep(thou)
	RETURN

// Tests that need to be moved in separate files in VO.Tests:
	[Fact, Trait("Category", "StringEq")];
	METHOD StringEquality() AS VOID
		LOCAL c1,c2 AS STRING
		LOCAL u1,u2 AS USUAL
		local exact as LOGIC
		u1 := c1 := "TESTLONG"
		u2 := c2 := "TEST"
		exact := SetExact( FALSE )

		Assert.Equal(true, c1 = c2)
		Assert.Equal(true, c1 != c2)

		Assert.Equal(true, u1 = u2)
		Assert.Equal(false, u1 != u2)

		SetExact( exact )
	RETURN

	[Fact, Trait("Category", "Str")];
	METHOD StrTests() AS VOID
		local exact,thou,digit,decimal,fixed_,digitfixed as usual
		exact := SetDecimalSep(Asc("."))
		thou := SetThousandSep(Asc(","))
		digit := SetDigit(6)
		decimal := SetDecimal(3)
		fixed_ := SetFixed(FALSE)
		digitfixed := SetDigitFixed(FALSE)

		Assert.Equal( "     1.2"			, Str(1.2) )
		Assert.Equal( "    12.3"			, Str(12.3) )
		Assert.Equal( "    12.34"			, Str(12.34) )
		Assert.Equal( "   123.456"			, Str(123.456) )
		Assert.Equal( "  1234.567"			, Str(1234.567) )
		Assert.Equal( "  1234.5678"			, Str(1234.5678) )
		Assert.Equal( "  1234.5679012345"	, Str(1234.5679012345) )
		Assert.Equal( "123456.78901234567"	, Str(123456.78901234567) )
		Assert.Equal( "999999" , Str(999999) )
		Assert.Equal( "******" , Str(1000000) )

		SetDecimalSep(exact)
		SetThousandSep(thou)
		SetDigit(digit)
		SetDecimal(decimal)
		SetFixed(fixed_)
		SetDigitFixed(digitfixed)
	RETURN

	[Fact, Trait("Category", "Val")];
	METHOD ValTests() AS VOID
		Assert.Equal(123, (int) Val("123") )
		Assert.Equal(123.456, (real8) Val("123.456") )

		Assert.Equal(0, (int) Val("") )

		Assert.Equal(0, (int) Val("abc") )
		Assert.Equal(123, (int) Val("123abc") )
		Assert.Equal(123, (int) Val("123abc456") )
		Assert.Equal(123, (int) Val("123abc456.789") )
		Assert.Equal(0, (INT) Val("abc123456.789") )
		Assert.Equal(255, (INT) Val("0xFF") )
		Assert.Equal(0xFFFF, (INT) Val("0xFFFF") )
		Assert.Equal(4294967295, (INT64) Val("0xFFFFFFFF") )
		Assert.Equal(11, (INT) Val("11L11") )
		Assert.Equal(1.000, (REAL8) Val("1,000.1") )
		Assert.Equal(1.001, (real8) Val("1,001.1") )
	RETURN

	[Fact, Trait("Category", "SplitPath")];
	METHOD SplitPathTests() AS VOID
		LOCAL cDrive := "",cDir := "",cFile := "",cExt := "" AS STRING
		SplitPath("C:\folder\file.ext" ,  cDrive , cDir , cFile , cExt)

		Assert.Equal("C:" , cDrive)
		Assert.Equal("\folder\" , cDir)

		Assert.Equal("file" , cFile)
		Assert.Equal(".ext" , cExt)
	RETURN

	[Fact, Trait("Category", "SplitPathVO")];
	METHOD SplitPathVO() AS VOID
		LOCAL cPath ,cDrive ,cDir ,cFile ,cExt AS STRING
		LOCAL pszDrive, pszDir AS PSZ
		LOCAL pszFile, pszExt AS PSZ

		cPath := "C:\testfolder\testfile.prg"

		pszDrive := MemAlloc(2+1)
		pszDir   := MemAlloc(255+1)
		pszFile  := MemAlloc(255+1)
		pszExt   := MemAlloc(7+1)

		SplitPath(String2Psz(cPath), pszDrive, pszDir,        ;
			 pszFile, pszExt)

		cDrive := Psz2String(pszDrive)
		cDir   := Psz2String(pszDir)
		cFile  := Psz2String(pszFile)
		cExt   := Psz2String(pszExt)

		MemFree(pszDrive)
		MemFree(pszDir)
		MemFree(pszFile)
		MemFree(pszExt)

		Assert.Equal("\testfolder\" , cDir)
		Assert.Equal("\testfolder\" , cDir)
		Assert.Equal("testfile" , cFile)
		Assert.Equal(".prg" , cExt)
	RETURN

	end class
end NAMESPACE


generalize a bit

generalize a bit

-- Copyright (c) 2006 Portland State University.
-- This is an example program for the Omega programming language;
-- for more information, see:
--   http://www.cs.pdx.edu/~sheard/Omega/index.html
-- Research and development on Omega is supported by a grant
-- from the National Science Foundation.

-- Existential hiding and operators on anonymous sums

data Covert :: (a ~> *0) ~> *0 where
  Hide :: t x -> Covert t

toNat :: Int -> Covert Nat'
toNat 0 = Hide Z
toNat n = case toNat (n-1) of Hide b -> Hide(S b)

-- Copyright (c) 2006 Portland State University.
-- This is an example program for the Omega programming language;
-- for more information, see:
--   http://www.cs.pdx.edu/~sheard/Omega/index.html
-- Research and development on Omega is supported by a grant
-- from the National Science Foundation.

-- Existential hiding and operators on anonymous sums

data Covert :: (Nat ~> *0) ~> *0 where
  Hide :: t x -> Covert t

toNat :: Int -> Covert Nat'
toNat 0 = Hide Z
toNat n = case toNat (n-1) of Hide b -> Hide(S b)


source/QtCore/QSignalBlocker.prg: updated

Modified:
source/QtCore/QSignalBlocker.prg

/*

  Qt5xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 5

  Copyright (C) 2018 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>

*/

/*
  DO NOT EDIT THIS FILE - the content was created using a source code generator
*/

#include "hbclass.ch"

CLASS QSignalBlocker

   DATA pointer
   DATA self_destruction INIT .F.

   METHOD new
   METHOD delete

   METHOD reblock
   METHOD unblock

   METHOD newFrom
   METHOD newFromObject
   METHOD newFromPointer
   METHOD selfDestruction
   METHOD setSelfDestruction

   DESTRUCTOR destroyObject

END CLASS

PROCEDURE destroyObject () CLASS QSignalBlocker
   IF ::self_destruction
      ::delete()
   ENDIF
RETURN

#pragma BEGINDUMP

#include <Qt>

#ifndef __XHARBOUR__
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
#include <QSignalBlocker>
#endif
#endif

#include "qt5xhb_common.h"
#include "qt5xhb_macros.h"
#include "qt5xhb_utils.h"

#ifdef __XHARBOUR__
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
#include <QSignalBlocker>
#endif
#endif

/*
explicit QSignalBlocker(QObject *o) Q_DECL_NOTHROW
*/
HB_FUNC_STATIC( QSIGNALBLOCKER_NEW )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  if( ISNUMPAR(1) && ISQOBJECT(1) )
  {
    QSignalBlocker * o = new QSignalBlocker ( PQOBJECT(1) );
    _qt5xhb_returnNewObject( o, true );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
#endif
}

/*
explicit QSignalBlocker(QObject &o) Q_DECL_NOTHROW
*/

//[1]explicit QSignalBlocker(QObject *o) Q_DECL_NOTHROW
//[2]explicit QSignalBlocker(QObject &o) Q_DECL_NOTHROW

/*
~QSignalBlocker()
*/
HB_FUNC_STATIC( QSIGNALBLOCKER_DELETE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QSignalBlocker * obj = (QSignalBlocker *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    delete obj;
    obj = NULL;
    PHB_ITEM self = hb_stackSelfItem();
    PHB_ITEM ptr = hb_itemPutPtr( NULL, NULL );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
  }

  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
void reblock() Q_DECL_NOTHROW
*/
HB_FUNC_STATIC( QSIGNALBLOCKER_REBLOCK )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QSignalBlocker * obj = (QSignalBlocker *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(0) )
    {
      obj->reblock ();
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
void unblock() Q_DECL_NOTHROW
*/
HB_FUNC_STATIC( QSIGNALBLOCKER_UNBLOCK )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QSignalBlocker * obj = (QSignalBlocker *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(0) )
    {
      obj->unblock ();
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
#endif
}

HB_FUNC_STATIC( QSIGNALBLOCKER_NEWFROM )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISOBJECT(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else if( hb_pcount() == 1 && ISPOINTER(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_param(1, HB_IT_POINTER ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }

  hb_itemReturn( self );
}

HB_FUNC_STATIC( QSIGNALBLOCKER_NEWFROMOBJECT )
{
  HB_FUNC_EXEC( QSIGNALBLOCKER_NEWFROM );
}

HB_FUNC_STATIC( QSIGNALBLOCKER_NEWFROMPOINTER )
{
  HB_FUNC_EXEC( QSIGNALBLOCKER_NEWFROM );
}

HB_FUNC_STATIC( QSIGNALBLOCKER_SELFDESTRUCTION )
{
  hb_retl( (bool) hb_itemGetL( hb_objSendMsg( hb_stackSelfItem(), "SELF_DESTRUCTION", 0 ) ) );
}

HB_FUNC_STATIC( QSIGNALBLOCKER_SETSELFDESTRUCTION )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISLOG(1) )
  {
    PHB_ITEM des = hb_itemPutL( NULL, hb_parl(1) );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }

  hb_itemReturn( self );
}

#pragma ENDDUMP

/*

  Qt5xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 5

  Copyright (C) 2018 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>

*/

/*
  DO NOT EDIT THIS FILE - the content was created using a source code generator
*/

#include "hbclass.ch"

CLASS QSignalBlocker

   DATA pointer
   DATA self_destruction INIT .F.

   METHOD new
   METHOD delete

   METHOD reblock
   METHOD unblock

   METHOD newFrom
   METHOD newFromObject
   METHOD newFromPointer
   METHOD selfDestruction
   METHOD setSelfDestruction

   DESTRUCTOR destroyObject

END CLASS

PROCEDURE destroyObject () CLASS QSignalBlocker
   IF ::self_destruction
      ::delete()
   ENDIF
RETURN

#pragma BEGINDUMP

#include <Qt>

#ifndef __XHARBOUR__
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
#include <QSignalBlocker>
#endif
#endif

#include "qt5xhb_common.h"
#include "qt5xhb_macros.h"
#include "qt5xhb_utils.h"

#ifdef __XHARBOUR__
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
#include <QSignalBlocker>
#endif
#endif

/*
explicit QSignalBlocker(QObject *o) Q_DECL_NOTHROW
*/
HB_FUNC_STATIC( QSIGNALBLOCKER_NEW )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  if( ISNUMPAR(1) && ISQOBJECT(1) )
  {
    QSignalBlocker * o = new QSignalBlocker ( PQOBJECT(1) );
    _qt5xhb_returnNewObject( o, false );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
#endif
}

/*
explicit QSignalBlocker(QObject &o) Q_DECL_NOTHROW
*/

//[1]explicit QSignalBlocker(QObject *o) Q_DECL_NOTHROW
//[2]explicit QSignalBlocker(QObject &o) Q_DECL_NOTHROW

/*
~QSignalBlocker()
*/
HB_FUNC_STATIC( QSIGNALBLOCKER_DELETE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QSignalBlocker * obj = (QSignalBlocker *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    delete obj;
    obj = NULL;
    PHB_ITEM self = hb_stackSelfItem();
    PHB_ITEM ptr = hb_itemPutPtr( NULL, NULL );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
  }

  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
void reblock() Q_DECL_NOTHROW
*/
HB_FUNC_STATIC( QSIGNALBLOCKER_REBLOCK )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QSignalBlocker * obj = (QSignalBlocker *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(0) )
    {
      obj->reblock ();
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
void unblock() Q_DECL_NOTHROW
*/
HB_FUNC_STATIC( QSIGNALBLOCKER_UNBLOCK )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QSignalBlocker * obj = (QSignalBlocker *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUMPAR(0) )
    {
      obj->unblock ();
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
#endif
}

HB_FUNC_STATIC( QSIGNALBLOCKER_NEWFROM )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISOBJECT(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else if( hb_pcount() == 1 && ISPOINTER(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_param(1, HB_IT_POINTER ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }

  hb_itemReturn( self );
}

HB_FUNC_STATIC( QSIGNALBLOCKER_NEWFROMOBJECT )
{
  HB_FUNC_EXEC( QSIGNALBLOCKER_NEWFROM );
}

HB_FUNC_STATIC( QSIGNALBLOCKER_NEWFROMPOINTER )
{
  HB_FUNC_EXEC( QSIGNALBLOCKER_NEWFROM );
}

HB_FUNC_STATIC( QSIGNALBLOCKER_SELFDESTRUCTION )
{
  hb_retl( (bool) hb_itemGetL( hb_objSendMsg( hb_stackSelfItem(), "SELF_DESTRUCTION", 0 ) ) );
}

HB_FUNC_STATIC( QSIGNALBLOCKER_SETSELFDESTRUCTION )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISLOG(1) )
  {
    PHB_ITEM des = hb_itemPutL( NULL, hb_parl(1) );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }

  hb_itemReturn( self );
}

#pragma ENDDUMP