uniform legenda

uniform legenda

#!/usr/bin/env gnuplot

# graph of CPU temperature

# datafile
ifname = "/tmp/sql11.csv"
ofname = "/tmp/lnxdiagd/site/img/day11.png"

# ******************************************************* General settings *****
# set terminal png font "Vera" 11 size 640,480
set terminal png font "Vera" 10 size 640,304
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
set timestamp 'created: %Y-%m-%d %H:%M' bottom

# ************************************************************* Statistics *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifname using 2 name "X" nooutput

X_min = X_min + utc_offset - 946684800
X_max = X_max + utc_offset - 946684800

# ****************************************************************** Title *****
set title "CPU Temperature"
#"-".utc_offset."-"

# ***************************************************************** X-axis *****
set xlabel "Date/Time"       # X-axis label
set xdata time               # Define that data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xtics rotate by 40 right
set xrange [ X_min : X_max ]

# ***************************************************************** Y-axis *****
set ylabel "Temperature [degC]"
#set yrange [10:20]
set autoscale y

# **************************************************************** Y2-axis *****
# set y2label "Temperature [degC]"
# set autoscale y2
# set y2tics border

# ***************************************************************** Legend *****
set key outside bottom center horizontal box
set key samplen .2
set key reverse Left

# ***************************************************************** Output *****
set arrow from graph 0,graph 0 to graph 0,graph 1 nohead lc rgb "red" front
#set arrow from graph 1,graph 0 to graph 1,graph 1 nohead lc rgb "green" front
set object 1 rect from screen 0,0 to screen 1,1 behind
set object 1 rect fc rgb "#eeeeee" fillstyle solid 1.0 noborder
set object 2 rect from graph 0,0 to graph 1,1 behind
set object 2 rect fc rgb "#ffffff" fillstyle solid 1.0 noborder
set output ofname

# ***** PLOT *****
plot ifname  using ($2+utc_offset):4 title " Temperature [degC]" with points pt 5 ps 0.2 \
#    ,       using ($2+utc_offset):4 title " Temperature [degC]" axes x1y2  with dots\

#!/usr/bin/env gnuplot

# graph of CPU temperature

# datafile
ifname = "/tmp/sql11.csv"
ofname = "/tmp/lnxdiagd/site/img/day11.png"

# ******************************************************* General settings *****
# set terminal png font "Vera" 11 size 640,480
set terminal png font "Vera" 10 size 640,304
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
set timestamp 'created: %Y-%m-%d %H:%M' bottom

# ************************************************************* Statistics *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifname using 2 name "X" nooutput

X_min = X_min + utc_offset - 946684800
X_max = X_max + utc_offset - 946684800

# ****************************************************************** Title *****
set title "CPU Temperature"
#"-".utc_offset."-"

# ***************************************************************** X-axis *****
set xlabel "Date/Time"       # X-axis label
set xdata time               # Define that data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xtics rotate by 40 right
set xrange [ X_min : X_max ]

# ***************************************************************** Y-axis *****
set ylabel "Temperature [degC]"
#set yrange [10:20]
set autoscale y

# **************************************************************** Y2-axis *****
# set y2label "Temperature [degC]"
# set autoscale y2
# set y2tics border

# ***************************************************************** Legend *****
# generate a legend which is placed underneath the plot
#set key outside bottom center box title "-=legend=-"
set key default
set key box
set key samplen .2
set key inside vertical
set key left top

# ***************************************************************** Output *****
set arrow from graph 0,graph 0 to graph 0,graph 1 nohead lc rgb "red" front
#set arrow from graph 1,graph 0 to graph 1,graph 1 nohead lc rgb "green" front
set object 1 rect from screen 0,0 to screen 1,1 behind
set object 1 rect fc rgb "#eeeeee" fillstyle solid 1.0 noborder
set object 2 rect from graph 0,0 to graph 1,1 behind
set object 2 rect fc rgb "#ffffff" fillstyle solid 1.0 noborder
set output ofname

# ***** PLOT *****
plot ifname  using ($2+utc_offset):4 title " Temperature [degC]" with points pt 5 ps 0.2 \
#    ,       using ($2+utc_offset):4 title " Temperature [degC]" axes x1y2  with dots\


new benchmark script

new benchmark script

set term postscript enhanced color solid 20
set out 'result/benchmark.eps'
set log x
set grid
set xlabel 'Problem Size (NX^2)'
set ylabel 'Flop/s'
set yrange [0:]
set key left top
set format y "%2.1t{/Symbol \327}10^{%L}"
set format x "10^{%L}"
plot '< grep "PiTCH-" result/benchmark.txt' u ($3**2):8 t 'PiTCH', \
     '< grep PiTCHOpt result/benchmark.txt' u ($3**2):8 t 'Optimized PiTCH' , \
     '< grep NoTB result/benchmark.txt'     u ($3**2):8 t 'No Blocking'

set term postscript enhanced color solid 20
set out 'result/benchmark.eps'
set log x
set grid
set xlabel 'Problem Size (NX^2)'
set ylabel 'Flop/s'
set yrange [0:4e9]
set key left top
set format y "%2.1t{/Symbol \327}10^{%L}"
set format x "10^{%L}"
plot '< grep "PiTCH-" result/benchmark.txt' u ($3**2):8 t 'PiTCH', \
     '< grep PiTCHOpt result/benchmark.txt' u ($3**2):8 t 'Optimized PiTCH' , \
     '< grep NoTB result/benchmark.txt'     u ($3**2):8 t 'No Blocking'


Fix gnuplot file

Fix gnuplot file

# IMPORT-DATA stats stats.txt

set terminal pdf size 13.33cm,10cm linewidth 2.0
set output "speed.pdf"

set style line 11 lc rgb "#333333" lt 1
set border 3 back ls 11
set tics nomirror
# define grid
set style line 12 lc rgb "#333333" lt 0 lw 1
set grid back ls 12

set grid xtics ytics

set key top left

set yrange [0:4]

set xlabel 'Item Count [log_2(n)]'
set ylabel 'Run Time / n log_2n [Nanoseconds]'

#SQL DELETE FROM stats WHERE LOG(2, size) < 12

set title 'Super Scalar Sample Sort Test: Random'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "random"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 0 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 1 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: 80% Sorted'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "80pcsorted"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 2 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 3 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: 90% Sorted'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "90pcsorted"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 4 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 5 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: 99% Sorted'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "99pcsorted"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 6 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 7 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: 99.9% Sorted'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "99.9pcsorted"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 8 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 9 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: 90% Sorted + 10% Random Tail'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "tail90"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 10 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 11 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: 99% Sorted + 1% Random Tail'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "tail99"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 12 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 13 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: Sorted'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "sorted"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 14 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 15 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: Reverse Sorted'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "reverse"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 16 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 17 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: Many duplicates (A[i]=i^{16} mod floor(log_2 n)'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "many-dupes"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 18 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 19 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: Few spikes, lots of noise'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "few-spikes-with-noise"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 20 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 21 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: All Ones'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "ones"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 22 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 23 title "algo=stdsort" with linespoints

# IMPORT-DATA stats stats.txt

set terminal pdf size 13.33cm,10cm linewidth 2.0
set output "speed.pdf"

set style line 11 lc rgb "#333333" lt 1
set border 3 back ls 11
set tics nomirror
# define grid
set style line 12 lc rgb "#333333" lt 0 lw 1
set grid back ls 12

set grid xtics ytics

set key top left

set yrange [0:4]

set xlabel 'Item Count [log_2(n)]'
set ylabel 'Run Time / n log_2n [Nanoseconds]'

#SQL DELETE FROM stats WHERE LOG(2, size) < 12

set title 'Super Scalar Sample Sort Test: Random'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "random"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 0 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 1 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: 80% Sorted'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "80pcsorted"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 2 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 3 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: 90% Sorted'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "90pcsorted"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 4 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 5 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: 99% Sorted'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "99pcsorted"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 6 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 7 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: 99.9% Sorted'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "99.9pcsorted"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 8 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 9 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: 90% Sorted + 10% Random Tail'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "tail90"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 10 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 11 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: 99% Sorted + 1% Random Tail'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "tail99"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 12 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 13 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: Sorted'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "sorted"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 14 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 15 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: Reverse Sorted'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "reverse"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x
plot \
    'speed-data.txt' index 16 title "algo=ssssort" with linespoints, \
    'speed-data.txt' index 17 title "algo=stdsort" with linespoints

set title 'Super Scalar Sample Sort Test: Many duplicates (A[i]=i^{16} mod floor(log_2 n)'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "ones"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x

set title 'Super Scalar Sample Sort Test: All Ones'
## MULTIPLOT(algo) SELECT LOG(2, size) AS x,
## MEDIAN(time / (size * log(2, size)) * 1e6) AS y,
## MULTIPLOT
## FROM stats WHERE name = "ones"
## GROUP BY MULTIPLOT, x ORDER BY MULTIPLOT, x


smaller range

smaller range

#!/usr/bin/gnuplot

set datafile separator ';'

# Title of the plot
set title "Test graph"

# We want a grid
set grid

# Ignore missing values
#set datafile missing "NaN"

# X-axis label
set xlabel "Date/Time"

# set X-axis range to current date only
#set xrange ["$YESTERDAY":"$TODAY"]

# Y-axis ranges from 0 deg C to 100 deg C, same scale as for humidity
set yrange [15:20]

# Y2-axis set from 800 to 1200 kPa, used for barometric pressure
set autoscale y2

# place ticks on second Y2-axis
set y2tics border

# Title for Y-axis
set ylabel "Temperature [degC]"

# Title for Y2-axis
set y2label "Raw values [mV]"

# Define that data on X-axis should be interpreted as time
set xdata time

# Time in log-file is given in Unix format
set timefmt "%s"

# Display notation for time
set format x "%R"    # Display time in 24 hour notation on the X axis

# generate a legend which is placed underneath the plot
set key outside bottom center box title "--legend--"

# output into png file
set terminal png large
set output "/tmp/bonediagd/plot.png"

# Data columns are:
# 2 is Unix Epoch time
# 3 is TMP36 mV
# 4 is calculated temperature

# read data from file and generate plot
plot "/tmp/sql.csv" using 2:4 title "Temperature [degC]" with lines \
                ,"" using 2:3 title "Raw signal [mV]" with lines axes x1y2 \

#!/usr/bin/gnuplot

set datafile separator ';'

# Title of the plot
set title "Test graph"

# We want a grid
set grid

# Ignore missing values
#set datafile missing "NaN"

# X-axis label
set xlabel "Date/Time"

# set X-axis range to current date only
#set xrange ["$YESTERDAY":"$TODAY"]

# Y-axis ranges from 0 deg C to 100 deg C, same scale as for humidity
set yrange [15:25]

# Y2-axis set from 800 to 1200 kPa, used for barometric pressure
set autoscale y2

# place ticks on second Y2-axis
set y2tics border

# Title for Y-axis
set ylabel "Temperature [degC]"

# Title for Y2-axis
set y2label "Raw values [mV]"

# Define that data on X-axis should be interpreted as time
set xdata time

# Time in log-file is given in Unix format
set timefmt "%s"

# Display notation for time
set format x "%R"    # Display time in 24 hour notation on the X axis

# generate a legend which is placed underneath the plot
set key outside bottom center box title "--legend--"

# output into png file
set terminal png large
set output "/tmp/bonediagd/plot.png"

# Data columns are:
# 2 is Unix Epoch time
# 3 is TMP36 mV
# 4 is calculated temperature

# read data from file and generate plot
plot "/tmp/sql.csv" using 2:4 title "Temperature [degC]" with lines \
                ,"" using 2:3 title "Raw signal [mV]" with lines axes x1y2 \


Update demo code

Update demo code

help
help insert
help create

SHOW TYPES;
SHOW RELATIONS;

MATCH (p:Person);
MATCH (p:Person) WHERE id < 15;
MATCH (p:Person) WHERE id < 15 RETURN name;
MATCH (p:Person) WHERE id < 15 OR id > 990;
MATCH (p:Person) WHERE id < 15 AND id > 990;
MATCH (p1:Person)-[k:KNOWS]->(p2:Person);
MATCH (p1:Person)-[KNOWS]->(p1:Person); // error
MATCH (p1:Person)-[k:KNOWS]->(p2:Person) WHERE p1.id < 100;
MATCH (p1:Person)-[k:KNOWS]->(p2:Person) WHERE p1.id < 100 AND p1.age < p2.age;
MATCH (p1:Person)-[k:KNOWS]->(p2:Person) WHERE p1.id < 100 AND p1.age < p2.age RETURN p1.name, p2.name;
MATCH (p1:Person)-[k:KNOWS]->(p2:Person) WHERE p1.id < 100 AND p1.age < p2.age RETURN name; // error
MATCH (p1:Person)-[KNOWS]->(Person)-[KNOWS]->(p2:Person);

MATCH (p1:Person)-[k:KNOWS]->(p2:Person) WHERE p1.id = 12;
UPDATE RELATION Person(id = 12)-KNOWS SET num_years = 42;
MATCH (p1:Person)-[k:KNOWS]->(p2:Person) WHERE p1.id = 12;
DELETE RELATION Person(id = 12)-KNOWS;
MATCH (p1:Person)-[k:KNOWS]->(p2:Person) WHERE p1.id = 12;

MATCH (p1:Person)-[k:KNOWS]->(p2:Person) WHERE p1.id = 22;
DELETE NODE Person(id = 22);
MATCH (Person) WHERE id = 22;
MATCH (p1:Person)-[k:KNOWS]->(p2:Person) WHERE p1.id = 22;

CREATE TYPE T(a: int[]);
INSERT NODE T(3); // error
INSERT NODE T([true, false]); // error
INSERT NODE T([true, 5]); // error
INSERT NODE T([1,2]), T([]);
MATCH (T);
UPDATE NODE T(a=[1,2]) SET a = [1,2,3];
MATCH (T);
DELETE NODE T(a=[1,2,3]);
MATCH (T);
DROP TYPE T;
MATCH (T); // error

help
help insert
help create

SHOW TYPES;
SHOW RELATIONS;

MATCH (p:Person);
MATCH (p:Person) WHERE id < 15;
MATCH (p:Person) WHERE id < 15 RETURN name;
MATCH (p:Person) WHERE id < 15 OR id > 490;
MATCH (p:Person) WHERE id < 15 AND id > 490;
MATCH (p1:Person)-[k:KNOWS]->(p2:Person);
MATCH (p1:Person)-[KNOWS]->(p1:Person); // error
MATCH (p1:Person)-[k:KNOWS]->(p2:Person) WHERE p1.id < 100;
MATCH (p1:Person)-[k:KNOWS]->(p2:Person) WHERE p1.id < 100 AND p1.age < p2.age;
MATCH (p1:Person)-[k:KNOWS]->(p2:Person) WHERE p1.id < 100 AND p1.age < p2.age RETURN p1.name, p2.name;
MATCH (p1:Person)-[k:KNOWS]->(p2:Person) WHERE p1.id < 100 AND p1.age < p2.age RETURN name; // error
MATCH (p1:Person)-[KNOWS]->(Person)-[KNOWS]->(p2:Person);

MATCH (p1:Person)-[k:KNOWS]->(p2:Person) WHERE p1.id = 12;
UPDATE RELATION Person(id = 12)-KNOWS SET num_years = 42;
MATCH (p1:Person)-[k:KNOWS]->(p2:Person) WHERE p1.id = 12;
DELETE RELATION Person(id = 12)-KNOWS;
MATCH (p1:Person)-[k:KNOWS]->(p2:Person) WHERE p1.id = 12;

MATCH (p1:Person)-[k:KNOWS]->(p2:Person) WHERE p1.id = 22;
DELETE NODE Person(id = 22);
MATCH (Person) WHERE id = 22;
MATCH (p1:Person)-[k:KNOWS]->(p2:Person) WHERE p1.id = 22;

CREATE TYPE T(a: int[]);
INSERT NODE T(3); // error
INSERT NODE T([true, false]); // error
INSERT NODE T([true, 5]); // error
INSERT NODE T([1,2]), T([]);
MATCH (T);
UPDATE NODE T(a=[1,2]) SET a = [1,2,3];
MATCH (T);
DELETE NODE T(a=[1,2,3]);
MATCH (T);
DROP TYPE T;
MATCH (T); // error


update

update

# Tested with gnuplot 4.6 patchlevel 6

FN_IN = system("echo $FN_IN")
FN_OUT = system("echo $FN_OUT")

# Get the plot range
set terminal unknown
set xdata time
set timefmt "%y%m%d-%H%M%S"
plot \
FN_IN u 2:6:2:4:6:($6+$5) w boxxyerrorbars
X_MIN=GPVAL_DATA_X_MIN
X_MAX=GPVAL_DATA_X_MAX
Y_MIN=GPVAL_DATA_Y_MIN
Y_MAX=GPVAL_DATA_Y_MAX

set terminal pdfcairo enhanced size 12in, 4in
set output FN_OUT

set ylabel "Size (MB)" offset 2,0

set border (1 + 2) front lc rgb "#808080"
set xtics nomirror scale 0.5,0 tc rgb "#808080"
set ytics nomirror scale 0.5,0 tc rgb "#808080" ( \
"0"   0, \
"50"  50*1024*1024, \
"100" 100*1024*1024)
set tics front

set xdata time
set timefmt "%y%m%d-%H%M%S"
set format x "'%y"

set xrange [X_MIN:X_MAX]
set yrange [Y_MIN:Y_MAX]

set key top left

set style fill solid 0.15 noborder

# x  y  xlow  xhigh  ylow  yhigh
plot \
FN_IN u 2:6:2:4:6:($6+$5) w boxxyerrorbars not, \
""    u 2:6:(0):5         w vectors nohead lc rgb "red"  t "Created", \
""    u 2:($6+$5/2.0):1   w labels right offset -0.5,0 font ",10" not

# Tested with gnuplot 4.6 patchlevel 6

FN_IN = system("echo $FN_IN")
FN_OUT = system("echo $FN_OUT")

# Get the plot range
set terminal unknown
set xdata time
set timefmt "%y%m%d-%H%M%S"
plot \
FN_IN u 2:6:2:4:6:($6+$5) w boxxyerrorbars
X_MIN=GPVAL_DATA_X_MIN
X_MAX=GPVAL_DATA_X_MAX
Y_MIN=GPVAL_DATA_Y_MIN
Y_MAX=GPVAL_DATA_Y_MAX

set terminal pdfcairo enhanced size 12in, 4in
set output FN_OUT

set border (1 + 2) back lc rgb "#808080"
set xtics nomirror scale 0.5,0 tc rgb "#808080"
set ytics nomirror scale 0.5,0 tc rgb "#808080" (0, "10 MB" 10*1024*1024)

set xdata time
set timefmt "%y%m%d-%H%M%S"
set format x "'%y"

set xrange [X_MIN:X_MAX]
set yrange [Y_MIN:Y_MAX]

set key top left

set style fill solid 0.15 noborder

# x  y  xlow  xhigh  ylow  yhigh
plot \
FN_IN u 2:6:2:4:6:($6+$5) w boxxyerrorbars not, \
""    u 2:6:(0):5         w vectors nohead lc rgb "red"  t "Created", \
""    u 2:($6+$5/2.0):1   w labels right offset -0.5,0 font ",10" not


work around svn problems accessing working copies that have a symbolic link as last path component

git-svn-id: 4e7379b20b57f8e3dde5a0b7363f233184647162@1452 4e380d45-d1fd-0310-85a7-d18ec86df0ad

# This -*- Makefile -*- is intended for processing with GNU make.

############################################################################
#  Makefile.gnu
#
#  Part of the STXXL. See http://stxxl.sourceforge.net
#
#  Copyright (C) 2002-2007 Roman Dementiev <dementiev@mpi-sb.mpg.de>
#  Copyright (C) 2007-2008 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
#
#  Distributed under the Boost Software License, Version 1.0.
#  (See accompanying file LICENSE_1_0.txt or copy at
#  http://www.boost.org/LICENSE_1_0.txt)
############################################################################

TOPDIR	?= .

main: library

include make.settings

SUBDIRS	= common io mng containers algo stream lib utils

SUBDIRS-lib: $(SUBDIRS:%=lib-in-%)
SUBDIRS-tests: $(SUBDIRS:%=tests-in-%)
SUBDIRS-clean: $(SUBDIRS:%=clean-in-%)

# compute STXXL_CPPFLAGS/STXXL_LDLIBS for stxxl.mk
# don't include optimization, warning and debug flags
stxxl_mk_cppflags	+= $(STXXL_CPPFLAGS_CXX)
stxxl_mk_ldlibs		+= $(STXXL_LDLIBS_CXX)
stxxl_mk_cppflags	+= $$(STXXL_CPPFLAGS_STXXL)
stxxl_mk_ldlibs		+= $$(STXXL_LDLIBS_STXXL)
ifeq ($(strip $(USE_PMODE)),yes)
stxxl_mk_cppflags	+= $$(STXXL_CPPFLAGS_PARALLEL_MODE)
stxxl_mk_ldlibs		+= $$(STXXL_LDLIBS_PARALLEL_MODE)
endif
ifeq ($(strip $(USE_MCSTL)),yes)
stxxl_mk_cppflags	+= $$(STXXL_CPPFLAGS_MCSTL)
stxxl_mk_ldlibs		+= $$(STXXL_LDLIBS_MCSTL)
endif
ifeq ($(strip $(USE_BOOST)),yes)
stxxl_mk_cppflags	+= $$(STXXL_CPPFLAGS_BOOST)
stxxl_mk_ldlibs		+= $$(STXXL_LDLIBS_BOOST)
endif

# dummy target for initial creation of make.settings.local
config:

lib-in-lib:
	@# nothing to compile
lib-in-%:
	$(MAKE) -C $* lib

build-lib: SUBDIRS-lib
	$(MAKE) -C lib
	$(MAKE) -C common tools
	$(MAKE) -C utils tools

$(LIBNAME).stamp: build-lib
	$(RM) $@ $(LIBNAME).mk.tmp
	echo 'STXXL_CXX	 = $(COMPILER)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_CPPFLAGS	 = $(stxxl_mk_cppflags)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_LDLIBS	 = $(stxxl_mk_ldlibs)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_CPPFLAGS_STXXL	 = $(STXXL_SPECIFIC)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_LDLIBS_STXXL	 = $(STXXL_LDFLAGS) $(STXXL_LDLIBS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_LIBDEPS		 = $(STXXL_LIBDEPS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_CPPFLAGS_PARALLEL_MODE	 = $(PARALLEL_MODE_CPPFLAGS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_LDLIBS_PARALLEL_MODE	 = $(PARALLEL_MODE_LDFLAGS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_CPPFLAGS_MCSTL	 = $(MCSTL_CPPFLAGS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_LDLIBS_MCSTL	 = $(MCSTL_LDFLAGS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_CPPFLAGS_BOOST	 = $(BOOST_COMPILER_OPTIONS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_LDLIBS_BOOST	 = $(BOOST_LINKER_OPTIONS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_WARNFLAGS		 = $(WARNINGS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_DEBUGFLAGS		 = $(DEBUG)'	>> $(LIBNAME).mk.tmp
	cmp -s $(LIBNAME).mk.tmp $(LIBNAME).mk || mv $(LIBNAME).mk.tmp $(LIBNAME).mk
	$(RM) $(LIBNAME).mk.tmp
	touch $@

library: $(LIBNAME).stamp

# skip recompilation of existing library
library-fast:
ifeq (,$(wildcard lib/lib$(LIBNAME).$(LIBEXT)))
library-fast: library
endif

ifneq (,$(wildcard .svn))
lib-in-common: common/version_svn.defs

GET_SVNVERSION		?= LC_ALL=POSIX svnversion $(realpath $1)
GET_SVN_INFO		?= LC_ALL=POSIX svn info $(realpath $1)
GET_SVN_INFO_SED	?= sed
GET_SVN_INFO_DATE	?= $(call GET_SVN_INFO, $1) | $(GET_SVN_INFO_SED) -n -e '/Last Changed Date/{' -e 's/.*: //' -e 's/ .*//' -e 's/-//g' -e 'p' -e '}'
GET_SVN_INFO_REV	?= $(call GET_SVN_INFO, $1) | $(GET_SVN_INFO_SED) -n -e '/Last Changed Rev/s/.*: //p'
GET_SVN_INFO_BRANCH	?= $(call GET_SVN_INFO, $1) | $(GET_SVN_INFO_SED) -n -e '/URL/{' -e 's/.*\/svnroot\/stxxl//' -e '/branches/s/\/branches\///p' -e '}'

STXXL_SVN_BRANCH	:= $(shell $(call GET_SVN_INFO_BRANCH, .))

ifeq (,$(strip $(shell svnversion . | tr -d 0-9)))
# clean checkout - use svn info
STXXL_VERSION_DATE	:= $(shell $(call GET_SVN_INFO_DATE, .))
STXXL_VERSION_SVN_REV	:= $(shell $(call GET_SVN_INFO_REV, .))
else
# modified, mixed, ... checkout - use svnversion and today
STXXL_VERSION_DATE	:= $(shell date "+%Y%m%d")
STXXL_VERSION_SVN_REV	:= $(shell $(call GET_SVNVERSION, .))
endif

# get the svn revision of the MCSTL, if possible
ifneq (,$(strip $(MCSTL_ROOT)))
ifneq (,$(wildcard $(MCSTL_ROOT)/.svn))
ifeq (,$(strip $(shell $(call GET_SVNVERSION, $(MCSTL_ROOT)) | tr -d 0-9)))
# clean checkout - use svn info
MCSTL_VERSION_DATE	:= $(shell $(call GET_SVN_INFO_DATE, $(MCSTL_ROOT)))
MCSTL_VERSION_SVN_REV	:= $(shell $(call GET_SVN_INFO_REV, $(MCSTL_ROOT)))
else
# modified, mixed, ... checkout - use svnversion and today
MCSTL_VERSION_DATE	:= $(shell date "+%Y%m%d")
MCSTL_VERSION_SVN_REV	:= $(shell $(call GET_SVNVERSION, $(MCSTL_ROOT)))
endif
endif
endif

.PHONY: common/version_svn.defs
common/version_svn.defs:
	$(RM) $@.$(LIBNAME).tmp
	echo '#define STXXL_VERSION_STRING_DATE "$(STXXL_VERSION_DATE)"' >> $@.$(LIBNAME).tmp
	echo '#define STXXL_VERSION_STRING_SVN_REVISION "$(STXXL_VERSION_SVN_REV)"' >> $@.$(LIBNAME).tmp
	$(if $(STXXL_SVN_BRANCH), echo '#define STXXL_VERSION_STRING_SVN_BRANCH "$(STXXL_SVN_BRANCH)"' >> $@.$(LIBNAME).tmp)
	$(if $(MCSTL_VERSION_SVN_REV), echo '#define MCSTL_VERSION_STRING_DATE "$(MCSTL_VERSION_DATE)"' >> $@.$(LIBNAME).tmp)
	$(if $(MCSTL_VERSION_SVN_REV), echo '#define MCSTL_VERSION_STRING_SVN_REVISION "$(MCSTL_VERSION_SVN_REV)"' >> $@.$(LIBNAME).tmp)
	cmp -s $@ $@.$(LIBNAME).tmp || mv $@.$(LIBNAME).tmp $@
	$(RM) $@.$(LIBNAME).tmp
endif

tests-in-%: library-fast
	$(MAKE) -C $* tests

tests: SUBDIRS-tests

clean-in-%:
	$(MAKE) -C $* clean

clean: SUBDIRS-clean
	$(RM) common/version_svn.defs
	$(RM) $(LIBNAME).stamp $(LIBNAME).mk $(LIBNAME).mk.tmp

ifneq (,$(wildcard .svn))
VERSION		?= $(shell grep 'define *STXXL_VERSION_STRING_MA_MI_PL' common/version.cpp | cut -d'"' -f2)
PHASE		?= snapshot
DATE		?= $(shell date "+%Y%m%d")
REL_VERSION	:= $(VERSION)$(if $(strip $(DATE)),-$(DATE))
release:
	$(RM) -r reltmp stxxl-$(REL_VERSION).tar.gz stxxl-$(REL_VERSION).zip
	mkdir reltmp
	svn export . reltmp/stxxl-$(REL_VERSION)
	$(RM) -r reltmp/stxxl-$(REL_VERSION)/homepage
	echo '#define STXXL_VERSION_STRING_PHASE "$(PHASE)"' > reltmp/stxxl-$(REL_VERSION)/common/version.defs
	$(if $(strip $(DATE)),echo '#define STXXL_VERSION_STRING_DATE "$(DATE)"' >> reltmp/stxxl-$(REL_VERSION)/common/version.defs)
	cd reltmp && tar cf - stxxl-$(REL_VERSION) | gzip -9 > ../stxxl-$(REL_VERSION).tar.gz && zip -r ../stxxl-$(REL_VERSION).zip stxxl-$(REL_VERSION)/*
	$(RM) -r reltmp
	@echo
	@echo "Your release has been created in stxxl-$(REL_VERSION).tar.gz and stxxl-$(REL_VERSION).zip"
	@echo "The following files are modified and not committed:"
	@svn status -q
endif

.PHONY: main config library library-fast tests clean release

# This -*- Makefile -*- is intended for processing with GNU make.

############################################################################
#  Makefile.gnu
#
#  Part of the STXXL. See http://stxxl.sourceforge.net
#
#  Copyright (C) 2002-2007 Roman Dementiev <dementiev@mpi-sb.mpg.de>
#  Copyright (C) 2007-2008 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
#
#  Distributed under the Boost Software License, Version 1.0.
#  (See accompanying file LICENSE_1_0.txt or copy at
#  http://www.boost.org/LICENSE_1_0.txt)
############################################################################

TOPDIR	?= .

main: library

include make.settings

SUBDIRS	= common io mng containers algo stream lib utils

SUBDIRS-lib: $(SUBDIRS:%=lib-in-%)
SUBDIRS-tests: $(SUBDIRS:%=tests-in-%)
SUBDIRS-clean: $(SUBDIRS:%=clean-in-%)

# compute STXXL_CPPFLAGS/STXXL_LDLIBS for stxxl.mk
# don't include optimization, warning and debug flags
stxxl_mk_cppflags	+= $(STXXL_CPPFLAGS_CXX)
stxxl_mk_ldlibs		+= $(STXXL_LDLIBS_CXX)
stxxl_mk_cppflags	+= $$(STXXL_CPPFLAGS_STXXL)
stxxl_mk_ldlibs		+= $$(STXXL_LDLIBS_STXXL)
ifeq ($(strip $(USE_PMODE)),yes)
stxxl_mk_cppflags	+= $$(STXXL_CPPFLAGS_PARALLEL_MODE)
stxxl_mk_ldlibs		+= $$(STXXL_LDLIBS_PARALLEL_MODE)
endif
ifeq ($(strip $(USE_MCSTL)),yes)
stxxl_mk_cppflags	+= $$(STXXL_CPPFLAGS_MCSTL)
stxxl_mk_ldlibs		+= $$(STXXL_LDLIBS_MCSTL)
endif
ifeq ($(strip $(USE_BOOST)),yes)
stxxl_mk_cppflags	+= $$(STXXL_CPPFLAGS_BOOST)
stxxl_mk_ldlibs		+= $$(STXXL_LDLIBS_BOOST)
endif

# dummy target for initial creation of make.settings.local
config:

lib-in-lib:
	@# nothing to compile
lib-in-%:
	$(MAKE) -C $* lib

build-lib: SUBDIRS-lib
	$(MAKE) -C lib
	$(MAKE) -C common tools
	$(MAKE) -C utils tools

$(LIBNAME).stamp: build-lib
	$(RM) $@ $(LIBNAME).mk.tmp
	echo 'STXXL_CXX	 = $(COMPILER)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_CPPFLAGS	 = $(stxxl_mk_cppflags)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_LDLIBS	 = $(stxxl_mk_ldlibs)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_CPPFLAGS_STXXL	 = $(STXXL_SPECIFIC)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_LDLIBS_STXXL	 = $(STXXL_LDFLAGS) $(STXXL_LDLIBS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_LIBDEPS		 = $(STXXL_LIBDEPS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_CPPFLAGS_PARALLEL_MODE	 = $(PARALLEL_MODE_CPPFLAGS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_LDLIBS_PARALLEL_MODE	 = $(PARALLEL_MODE_LDFLAGS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_CPPFLAGS_MCSTL	 = $(MCSTL_CPPFLAGS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_LDLIBS_MCSTL	 = $(MCSTL_LDFLAGS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_CPPFLAGS_BOOST	 = $(BOOST_COMPILER_OPTIONS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_LDLIBS_BOOST	 = $(BOOST_LINKER_OPTIONS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_WARNFLAGS		 = $(WARNINGS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_DEBUGFLAGS		 = $(DEBUG)'	>> $(LIBNAME).mk.tmp
	cmp -s $(LIBNAME).mk.tmp $(LIBNAME).mk || mv $(LIBNAME).mk.tmp $(LIBNAME).mk
	$(RM) $(LIBNAME).mk.tmp
	touch $@

library: $(LIBNAME).stamp

# skip recompilation of existing library
library-fast:
ifeq (,$(wildcard lib/lib$(LIBNAME).$(LIBEXT)))
library-fast: library
endif

ifneq (,$(wildcard .svn))
lib-in-common: common/version_svn.defs

GET_SVN_INFO		?= LC_ALL=POSIX svn info $1
GET_SVN_INFO_SED	?= sed
GET_SVN_INFO_DATE	?= $(call GET_SVN_INFO, $1) | $(GET_SVN_INFO_SED) -n -e '/Last Changed Date/{' -e 's/.*: //' -e 's/ .*//' -e 's/-//g' -e 'p' -e '}'
GET_SVN_INFO_REV	?= $(call GET_SVN_INFO, $1) | $(GET_SVN_INFO_SED) -n -e '/Last Changed Rev/s/.*: //p'
GET_SVN_INFO_BRANCH	?= $(call GET_SVN_INFO, $1) | $(GET_SVN_INFO_SED) -n -e '/URL/{' -e 's/.*\/svnroot\/stxxl//' -e '/branches/s/\/branches\///p' -e '}'

STXXL_SVN_BRANCH	:= $(shell $(call GET_SVN_INFO_BRANCH, .))

ifeq (,$(strip $(shell svnversion . | tr -d 0-9)))
# clean checkout - use svn info
STXXL_VERSION_DATE	:= $(shell $(call GET_SVN_INFO_DATE, .))
STXXL_VERSION_SVN_REV	:= $(shell $(call GET_SVN_INFO_REV, .))
else
# modified, mixed, ... checkout - use svnversion and today
STXXL_VERSION_DATE	:= $(shell date "+%Y%m%d")
STXXL_VERSION_SVN_REV	:= $(shell svnversion .)
endif

# get the svn revision of the MCSTL, if possible
ifneq (,$(strip $(MCSTL_ROOT)))
ifneq (,$(wildcard $(MCSTL_ROOT)/.svn))
ifeq (,$(strip $(shell svnversion $(MCSTL_ROOT) | tr -d 0-9)))
# clean checkout - use svn info
MCSTL_VERSION_DATE	:= $(shell $(call GET_SVN_INFO_DATE, $(MCSTL_ROOT)))
MCSTL_VERSION_SVN_REV	:= $(shell $(call GET_SVN_INFO_REV, $(MCSTL_ROOT)))
else
# modified, mixed, ... checkout - use svnversion and today
MCSTL_VERSION_DATE	:= $(shell date "+%Y%m%d")
MCSTL_VERSION_SVN_REV	:= $(shell svnversion $(MCSTL_ROOT))
endif
endif
endif

.PHONY: common/version_svn.defs
common/version_svn.defs:
	$(RM) $@.$(LIBNAME).tmp
	echo '#define STXXL_VERSION_STRING_DATE "$(STXXL_VERSION_DATE)"' >> $@.$(LIBNAME).tmp
	echo '#define STXXL_VERSION_STRING_SVN_REVISION "$(STXXL_VERSION_SVN_REV)"' >> $@.$(LIBNAME).tmp
	$(if $(STXXL_SVN_BRANCH), echo '#define STXXL_VERSION_STRING_SVN_BRANCH "$(STXXL_SVN_BRANCH)"' >> $@.$(LIBNAME).tmp)
	$(if $(MCSTL_VERSION_SVN_REV), echo '#define MCSTL_VERSION_STRING_DATE "$(MCSTL_VERSION_DATE)"' >> $@.$(LIBNAME).tmp)
	$(if $(MCSTL_VERSION_SVN_REV), echo '#define MCSTL_VERSION_STRING_SVN_REVISION "$(MCSTL_VERSION_SVN_REV)"' >> $@.$(LIBNAME).tmp)
	cmp -s $@ $@.$(LIBNAME).tmp || mv $@.$(LIBNAME).tmp $@
	$(RM) $@.$(LIBNAME).tmp
endif

tests-in-%: library-fast
	$(MAKE) -C $* tests

tests: SUBDIRS-tests

clean-in-%:
	$(MAKE) -C $* clean

clean: SUBDIRS-clean
	$(RM) common/version_svn.defs
	$(RM) $(LIBNAME).stamp $(LIBNAME).mk $(LIBNAME).mk.tmp

ifneq (,$(wildcard .svn))
VERSION		?= $(shell grep 'define *STXXL_VERSION_STRING_MA_MI_PL' common/version.cpp | cut -d'"' -f2)
PHASE		?= snapshot
DATE		?= $(shell date "+%Y%m%d")
REL_VERSION	:= $(VERSION)$(if $(strip $(DATE)),-$(DATE))
release:
	$(RM) -r reltmp stxxl-$(REL_VERSION).tar.gz stxxl-$(REL_VERSION).zip
	mkdir reltmp
	svn export . reltmp/stxxl-$(REL_VERSION)
	$(RM) -r reltmp/stxxl-$(REL_VERSION)/homepage
	echo '#define STXXL_VERSION_STRING_PHASE "$(PHASE)"' > reltmp/stxxl-$(REL_VERSION)/common/version.defs
	$(if $(strip $(DATE)),echo '#define STXXL_VERSION_STRING_DATE "$(DATE)"' >> reltmp/stxxl-$(REL_VERSION)/common/version.defs)
	cd reltmp && tar cf - stxxl-$(REL_VERSION) | gzip -9 > ../stxxl-$(REL_VERSION).tar.gz && zip -r ../stxxl-$(REL_VERSION).zip stxxl-$(REL_VERSION)/*
	$(RM) -r reltmp
	@echo
	@echo "Your release has been created in stxxl-$(REL_VERSION).tar.gz and stxxl-$(REL_VERSION).zip"
	@echo "The following files are modified and not committed:"
	@svn status -q
endif

.PHONY: main config library library-fast tests clean release


Add more UTs for key_conflict

Add more UTs for key_conflict

:- begin_tests(db_i).
:- use_module(u(v)).
:- use_module(u(vd)).
:- use_module(u(internal/objects_i)).
:- use_module(u(internal/db_i)).
:- use_module(u(internal/db_vocab)).

test(db_next_class_id, [setup(setup)]) :-

	db_i:db_next_class_id(db_i_test, Id1),
	assertion(Id1 =:= 2),
	db_i:db_next_class_id(db_i_test, Id2),
	assertion(Id2 =:= 3),
	db_i:db_next_class_id(db_i_test, Id3),
	assertion(Id3 =:= 4).

% test local class id -> db class id conversion
test(db_conv_local_db1, [setup(setup)]) :-

	obj_construct(man_v, [], [], Man1),
	obj_rebase((object_v -> db_object_v), Man1, Man),
	arg(1, Man, Man_Local_Id),

	db_i:db_add_class(db_i_test, Man_Local_Id, Man_DB_Id, _),

	db_conv_local_db(db_i_test, Man_Local_Id,
			 Man_DB_Id1,_),

	assertion(Man_DB_Id =:= Man_DB_Id1),

	% object_v
	class_id(Object_Local_Id, object_v), !,
	db_conv_local_db(db_i_test, Object_Local_Id,
			 Object_DB_Id, _),

	assertion(Object_DB_Id =:= 1), % always 1
	assertion(Man_DB_Id =\= Object_DB_Id).

test(db_recorded_int,
     [setup(setup),
      throws(error(no_object_field(Obj0, db_ref), _))]
    ) :-

        obj_construct(man_v, [sex, name], [man, 'Adam'], Obj0),
        db_put_object(db_i_test, Obj0, _),
        db_recorded_int(db_i_test, Obj0).

test(db_recorded_int, [setup(setup)]) :-

        obj_construct(man_v, [sex, name], [man, 'Adam'], Obj0),
        db_put_object(db_i_test, Obj0, Obj),
        db_recorded(db_i_test, Obj).

test(key_conflict, [setup(model_db(Slod1))]) :-

   obj_construct(man_v,
                 [name, surname], ['Sergei', 'Lodyagin'], Man1_0),
   obj_rebase((object_v -> db_object_v), Man1_0, Man1),

   arg(1, Man1, Man_V_Re_Id),

   findall(C,
           key_conflict(people, Man_V_Re_Id, Man1, C),
           List1),
   assertion(List1 =@= [Slod1]),

   obj_construct(man_v, [name], ['Sergei'], Man2_0),
   obj_rebase((object_v -> db_object_v), Man2_0, Man2),

   findall(Name,
           (  key_conflict(people, Man_V_Re_Id, Man2, O),
              obj_field(O, surname, Name)
           ),
           List2),
   assertion(List2 =@= ['Lodyagin', 'Sikorsky'
                        %'Sysoev', 'Ivan'
                        % (man_v is not desc. of citizen_v)
                        ]),

   obj_construct(man_v, [], [], Man3_0),
   obj_rebase((object_v -> db_object_v), Man3_0, Man3),

   findall(C,
           key_conflict(people, Man_V_Re_Id, Man3, C),
           List3),
   length(List3, N3),
   assertion(N3 =:= 5),

   obj_construct(citizen_v, [name, id], ['Sergei', 4], Man4_0),
   obj_rebase((object_v -> db_object_v), Man4_0, Man4),

   arg(1, Man4, Citizen_V_Re_Id),

   findall(Name,
           (  key_conflict(people, Citizen_V_Re_Id, Man4, O),
              obj_field(O, surname, Name)
           ),
           List4),
   assertion(List4 =@= ['Lodyagin', 'Sikorsky', 'Sysoev']),

   obj_construct(citizen_v,
                 [name, surname, id],
                 ['Igor', 'Litvin', 4], Man5_0),
   obj_rebase((object_v -> db_object_v), Man5_0, Man5),

   findall(Name,
           (  key_conflict(people, Citizen_V_Re_Id, Man5, O),
              obj_field(O, surname, Name)
           ),
           List5),
   assertion(List5 =@= ['Sysoev']).

model_db(Slod1) :-

   db_clear(people),
   db_construct(people, man_v,
                [name, surname], ['Sergei', 'Lodyagin'], Slod1),

   db_construct(people, man_v,
                [name, surname], ['Sergei', 'Sikorsky']),
   db_construct(people, man_v, [name], ['Ivan']),
   db_construct(people, man_v,
                [name, surname], ['Artemiy', 'Lodyagin']),
   db_construct(people, man_v,
                [name, surname], ['Artemiy', 'Lebedev']),
   db_construct(people, citizen_v,
                [name, surname, id], ['Sergei', 'Sysoev', 4]),
   db_construct(people, citizen_v,
                [name, surname, id], ['Sergei', 'Ivan', 5]).

setup :-

	db_clear(db_i_test).

:- end_tests(db_i).

:- begin_tests(db_i).
:- use_module(u(v)).
:- use_module(u(vd)).
:- use_module(u(internal/objects_i)).
:- use_module(u(internal/db_i)).
:- use_module(u(internal/db_vocab)).

test(db_next_class_id, [setup(setup)]) :-

	db_i:db_next_class_id(db_i_test, Id1),
	assertion(Id1 =:= 2),
	db_i:db_next_class_id(db_i_test, Id2),
	assertion(Id2 =:= 3),
	db_i:db_next_class_id(db_i_test, Id3),
	assertion(Id3 =:= 4).

% test local class id -> db class id conversion
test(db_conv_local_db1, [setup(setup)]) :-

	obj_construct(man_v, [], [], Man1),
	obj_rebase((object_v -> db_object_v), Man1, Man),
	arg(1, Man, Man_Local_Id),

	db_i:db_add_class(db_i_test, Man_Local_Id, Man_DB_Id, _),

	db_conv_local_db(db_i_test, Man_Local_Id,
			 Man_DB_Id1,_),

	assertion(Man_DB_Id =:= Man_DB_Id1),

	% object_v
	class_id(Object_Local_Id, object_v), !,
	db_conv_local_db(db_i_test, Object_Local_Id,
			 Object_DB_Id, _),

	assertion(Object_DB_Id =:= 1), % always 1
	assertion(Man_DB_Id =\= Object_DB_Id).

test(db_recorded_int,
     [setup(setup),
      throws(error(no_object_field(Obj0, db_ref), _))]
    ) :-

        obj_construct(man_v, [sex, name], [man, 'Adam'], Obj0),
        db_put_object(db_i_test, Obj0, _),
        db_recorded_int(db_i_test, Obj0).

test(db_recorded_int, [setup(setup)]) :-

        obj_construct(man_v, [sex, name], [man, 'Adam'], Obj0),
        db_put_object(db_i_test, Obj0, Obj),
        db_recorded(db_i_test, Obj).

test(key_conflict) :-

   db_clear(people),
   db_construct(people, man_v,
                [name, surname], ['Sergei', 'Lodyagin'], Slod1),

   db_construct(people, man_v,
                [name, surname], ['Sergei', 'Sikorsky']),
   db_construct(people, man_v, [name], ['Ivan']),
   db_construct(people, man_v,
                [name, surname], ['Artemiy', 'Lodyagin']),
   db_construct(people, man_v,
                [name, surname], ['Artemiy', 'Lebedev']),
   db_construct(people, citizen_v,
                [name, surname, id], ['Sergei', 'Sysoev', 4]),
   db_construct(people, citizen_v,
                [name, surname, id], ['Sergei', 'Ivan', 5]),

   obj_construct(man_v,
                 [name, surname], ['Sergei', 'Lodyagin'], Man0),
   obj_rebase((object_v -> db_object_v), Man0, Man),

   arg(1, Man, Man_V_Re_Id),
   findall(C,
           key_conflict(people, Man_V_Re_Id, Man, C),
           List1),
   assertion(List1 =@= [Slod1]).

setup :-

	db_clear(db_i_test).

:- end_tests(db_i).


Add prettier plotting.

Add prettier plotting.

set terminal pdf mono font '/usr/share/fonts/X11/Type1/lmbx10.pfb'
set termoption dash
set output 'plot.pdf'
set key inside right bottom box linetype -1 linewidth 1.000
set samples 50
set title "40-bit one max"
set yrange [0:45]
set xlabel "Generation"
set ylabel "Fitness"

S = 1
plot "data.dat" u 1:2:3 t "Average + std.dev" w yerrorlines lt 1 lc rgb 'blue',\
     "data.dat" u 1:4 t "Max" w l lt 1 lc rgb 'web-green', \
     "data.dat" u 1:5 t "Min" w l lt 1 lc rgb 'dark-red',\
     40 t "" w l lc rgb 'gray'

set terminal pdf mono font '/usr/share/fonts/X11/Type1/lmbx10.pfb'
set output 'plot.pdf'
#set key inside left top box linetype -1 linewidth 1.000
unset key
set samples 50
set title "40-bit one max"
set xlabel "Generation"
set ylabel "Fitness"
S = 1
plot "data.dat" u 1:2:3 t "Average + std.dev" w yerrorlines lc rgb 'blue', \
     "data.dat" u 1:4 t "Max" w l lc rgb 'web-green', \
     "data.dat" u 1:5 t "Min" w l lc rgb 'dark-red'


Update script for visual check of "SimplexOptimizerTest" debugging output.

Allow displaying negative values of the objective function.

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
#

#
# "Gnuplot" script to display the behaviour of simplex-based optimizers.
#
# Required argument:
#   file -> input file (cf. "SimplexOptimizerTest").
# Optional argument:
#   showSpx -> Number of simplexes to show.
#

set term x11

showSpx = exists("showSpx") ? showSpx : 5

stats file nooutput
numOptim = STATS_blocks
evalColIndex = 1
objColIndex = 2
absObjDiffColIndex = 3
xColIndex = 4
yColIndex = 5

set size 1, 1
set origin 0, 0

lastOptim = numOptim - 1
do for [iOptim = 1:lastOptim] {

  # Evaluations range.
  stats file u evalColIndex nooutput
  numEval = STATS_max

  # Objective function range.
  # Using the absolute value of the difference with the objective function
  # at the optimum in order to be able to display the logarithm even if the
  # objective function can be negative.
  stats file index iOptim u absObjDiffColIndex nooutput
  numSpx = STATS_blank
  minObj = STATS_min
  maxObj = STATS_max

  # x-coordinate range.
  stats file index iOptim u xColIndex nooutput
  xMin = STATS_min
  xMax = STATS_max

  # y-coordinate range.
  stats file index iOptim u yColIndex nooutput
  yMin = STATS_min
  yMax = STATS_max

  lastSpx = numSpx - 1
  do for [iSpx = 0:lastSpx] {
    set multiplot

    # Number of evaluations.
    set size 1, 0.2
    set origin 0, 0.8
    unset xtics

    set title file . " - optimization " . iOptim . " - iteration " . iSpx noenhanced
    plot \
       file index iOptim \
         every ::0::0 \
         u 0:1 \
         w p ps 0.5 lc "black" title "N_{eval}", \
       '' index iOptim \
         every ::0::0:iSpx \
         u 0:1 \
         w lp pt 1 lc "black" lw 2 notitle
    unset title

    # Objective function.
    set size 1, 0.2
    set origin 0, 0.6

    plot \
       file index iOptim \
         every ::0::2 \
         u 0:(log($3)) \
         w l lc "black" title "log_{10}|f(x) - f(optimum)|", \
       '' index iOptim \
         every ::0::2:iSpx \
         u 0:(log($3)) \
         w lp pt 1 lc "black" lw 2 notitle

    # Simplex.
    set size 1, 0.6
    set origin 0, 0
    set xtics

    unset log y
    plot [xMin:xMax][yMin:yMax] \
      file index iOptim \
        every :::(iSpx - showSpx < 0 ? 0 : iSpx - showSpx)::iSpx \
        u xColIndex:yColIndex \
        w l notitle, \
      '' index "Optimum" \
        u 1:2 ps 2.5 pt 4 title "Expected", \
      '' index iOptim \
        every :::lastSpx::lastSpx \
        u xColIndex:yColIndex ps 1.5 pt 6 title "Found"

    unset multiplot
    pause 0.15
  }

  pause 1
}

pause -1

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
#

#
# "Gnuplot" script to display the behaviour of simplex-based optimizers.
#
# Required argument:
#   file -> input file (cf. "SimplexOptimizerTest").
# Optional argument:
#   showSpx -> Number of simplexes to show.
#

set term x11

showSpx = exists("showSpx") ? showSpx : 5

stats file nooutput
numOptim = STATS_blocks
evalColIndex = 1
objColIndex = 2
xColIndex = 3
yColIndex = 4

set size 1, 1
set origin 0, 0

lastOptim = numOptim - 1
do for [iOptim = 1:lastOptim] {

  # Evaluations range.
  stats file u evalColIndex nooutput
  numEval = STATS_max

  # Objective function range.
  stats file index iOptim u objColIndex nooutput
  numSpx = STATS_blank
  minObj = STATS_min
  maxObj = STATS_max

  # x-coordinate range.
  stats file index iOptim u xColIndex nooutput
  xMin = STATS_min
  xMax = STATS_max

  # y-coordinate range.
  stats file index iOptim u yColIndex nooutput
  yMin = STATS_min
  yMax = STATS_max

  lastSpx = numSpx - 1
  do for [iSpx = 0:lastSpx] {
    set multiplot

    # Number of evaluations.
    set size 1, 0.2
    set origin 0, 0.8
    unset xtics

    set title file . " - optimization " . iOptim . " - iteration " . iSpx noenhanced
    plot \
       file index iOptim \
         every ::0::0 \
         u 0:1 \
         w p ps 0.5 lc "black" title "N_{eval}", \
       '' index iOptim \
         every ::0::0:iSpx \
         u 0:1 \
         w lp pt 1 lc "black" lw 2 notitle
    unset title

    # Objective function.
    set size 1, 0.2
    set origin 0, 0.6

    plot \
       file index iOptim \
         every ::0::2 \
         u 0:(log($2)) \
         w l lc "black" title "log_{10}f", \
       '' index iOptim \
         every ::0::2:iSpx \
         u 0:(log($2)) \
         w lp pt 1 lc "black" lw 2 notitle

    # Simplex.
    set size 1, 0.6
    set origin 0, 0
    set xtics

    unset log y
    plot [xMin:xMax][yMin:yMax] \
      file index iOptim \
        every :::(iSpx - showSpx < 0 ? 0 : iSpx - showSpx)::iSpx \
        u xColIndex:yColIndex \
        w l notitle, \
      '' index "Optimum" u 1:2 ps 5 pt 4 notitle

    unset multiplot
    pause 0.1
  }

  pause 1
}

pause -1


inkdisplay: x tics set hourly

inkdisplay: x tics set hourly

set terminal png size 600,370
set output "/tmp/graphs.png"

set datafile separator " "

set size 1,1
set origin 0,0

set tmargin 0.5
set bmargin 0.5
# set lmargin 3
# set rmargin 3

set terminal png linewidth 2
set ytics font "Fira Mono Bold, 12"

set xtics format " "
set xtics 3600

set multiplot layout 3,1 columnsfirst scale 1,1

set yrange [0:80]
set ytics 10,20
plot "/tmp/plotdata.csv" using 1:2 with lines title "luminosity" lt rgb "black"
set ytics 18,4
set yrange [16:28]
plot "/tmp/plotdata.csv" using 1:3 with lines title "temperature" lt rgb "black"
set ytics 30,10
set yrange [25:65]
plot "/tmp/plotdata.csv" using 1:4 with lines title "humidity" lt rgb "black"

unset multiplot

set terminal png size 600,370
set output "/tmp/graphs.png"

set datafile separator " "

set size 1,1
set origin 0,0

set tmargin 0.5
set bmargin 0.5
# set lmargin 3
# set rmargin 3

set terminal png linewidth 2
set ytics font "Fira Mono Bold, 12"

set xtics format " "

set multiplot layout 3,1 columnsfirst scale 1,1

set yrange [0:80]
set ytics 10,20
plot "/tmp/plotdata.csv" using 1:2 with lines title "luminosity" lt rgb "black"
set ytics 18,4
set yrange [16:28]
plot "/tmp/plotdata.csv" using 1:3 with lines title "temperature" lt rgb "black"
set ytics 30,10
set yrange [25:65]
plot "/tmp/plotdata.csv" using 1:4 with lines title "humidity" lt rgb "black"

unset multiplot


[examples] improve gnuplot file for NE_1DS_1Knee

resultfile ="NE_1DS_1Knee_MLCP.dat"
resultfile_ref ="NE_1DS_1Knee_MLCP.ref"
#resultfile ="NE_1DS_1Knee_MLCP_D1MinusLinear.dat"
#resultfile_ref ="NE_1DS_1Knee_MLCP_D1MinusLinear.ref"

#plot resultfile u 1:2
resultfile1 ="NE_1DS_1Knee_MLCP_beam1.dat"
#resultfile1 ="NE_1DS_1Knee_MLCP_D1MinusLinear_beam1.dat"

set label 1 sprintf("Siconos NewtonEulerDS simulation.")  at first 0.5 , first 0.5
i=0
set term aqua 0
plot resultfile1 u 3*i+1:3*i+3 w lp t 'beam1'
set term aqua 1
plot  resultfile u 1:9 w l t 'norm2(y)'
set term aqua 2
plot  resultfile u 1:10 w l t 'norm2(ydot)'
set term aqua 3
set xrange [.0:0.5]
plot  resultfile u 1:2 w l t 'q[1]',\
resultfile_ref every ::1  u 1:2 w l t 'q[1]'

set term gif animate

outputfile="animatedonebeam.gif"
outputfile="animatedonebeam_D1MinusLinear.gif"
set label 1 sprintf("Siconos NewtonEulerDS simulation.")  at first -0.5 , first 0.5

set xrange [-1.05:1.05]
set yrange [-2:0.1]
set size square
set output outputfile
n=1000   #n frames
#n=50
i=0
every=5

load "animonebeam.gp"

resultfile ="NE_1DS_1Knee_MLCP.dat"
resultfile ="NE_1DS_1Knee_MLCP_D1MinusLinear.dat"

#plot resultfile u 1:2
#resultfile1 ="NE_1DS_1Knee_MLCP_beam1.dat"
#resultfile1 ="NE_1DS_1Knee_MLCP_D1MinusLinear_beam1.dat"

set label 1 sprintf("Siconos NewtonEulerDS simulation.")  at first 0.5 , first 0.5
i=0
set term aqua 0
#plot resultfile1 u 3*i+1:3*i+3 w lp t 'beam1'
set term aqua 1
plot  resultfile u 1:9 w l t 'norm2(y)'
set term aqua 2
plot  resultfile u 1:10 w l t 'norm2(ydot)'
set term gif animate

outputfile="animatedonebeam.gif"
outputfile="animatedonebeam_D1MinusLinear.gif"
set label 1 sprintf("Siconos NewtonEulerDS simulation.")  at first -0.5 , first 0.5

set xrange [-1.05:1.05]
set yrange [-2:0.1]
set size square
set output outputfile
n=1000   #n frames
#n=50
i=0
every=5

#load "animonebeam.gp"


Add more UT on v

Add more UT on v

:- begin_tests(v).
:- use_module(u(v)).
:- use_module(u(internal/objects_i)).
:- use_module(u(http/v/http_user_v)).

test(class_create1) :-
   % test class_create/3 version

   current_prolog_flag(verbose, Old_Verbose),
   set_prolog_flag(verbose, silent),
   reload_all_classes,
   set_prolog_flag(verbose, Old_Verbose),

   class_create(class_create_test_v, citizen_v, [a, c, b]),
   obj_construct(class_create_test_v, [birthday], [1976], CCTO),
   class_fields(citizen_v, CF), sort(CF, CFS),
   class_fields(class_create_test_v, CCTF), sort(CCTF, CCTFS),
   class_fields_new(class_create_test_v, CCTFN),
   assertion(CF == CFS),
   assertion(CCTF = CCTFS),
   assertion(CCTFN == [a, b, c]),

   ord_subtract(CCTF, CF, New_Fields),
   assertion(New_Fields == CCTFN),

   obj_field(CCTO, age, Age),
   integer(Age),

   obj_key(CCTO, Key),
   assertion(Key == [id]).

test(class_create2) :-
   % test class_create/4 version

   current_prolog_flag(verbose, Old_Verbose),
   set_prolog_flag(verbose, silent),
   reload_all_classes,
   set_prolog_flag(verbose, Old_Verbose),

   class_create(class_create_test_v, citizen_v, [a, c, b],
                [birthday, a]),
   obj_construct(class_create_test_v, [birthday], [1976], CCTO),
   class_fields(citizen_v, CF), sort(CF, CFS),
   class_fields(class_create_test_v, CCTF), sort(CCTF, CCTFS),
   class_fields_new(class_create_test_v, CCTFN),
   assertion(CF == CFS),
   assertion(CCTF = CCTFS),
   assertion(CCTFN == [a, b, c]),

   ord_subtract(CCTF, CF, New_Fields),
   assertion(New_Fields == CCTFN),

   obj_field(CCTO, age, Age),
   integer(Age),

   obj_key(CCTO, Key),
   assertion(Key == [a, birthday]).

test(class_create_feature1) :-
   % It is a strange feature

   current_prolog_flag(verbose, Old_Verbose),
   set_prolog_flag(verbose, silent),
   reload_all_classes,
   set_prolog_flag(verbose, Old_Verbose),

   class_create(class_create_test_v, citizen_v, [a, c, b], []),
   obj_construct(class_create_test_v, [birthday], [1976], CCTO),
   obj_key(CCTO, Key),
   assertion(Key == []).

% test(class_descendant1,
%      [List == [callup_v, citizen_v, class_create_test_v]]
%     ) :-

%   findall(X, class_descendant(man_v, X), List0),
%   msort(List0, List).

% test(class_descendant2, [List == []]) :-

%   findall(X, class_descendant(callup_v, X), List).

% test(class_descendant3, [List == []]) :-

%   obj_construct(tarjan_vertex_v, [], [], V),
%   obj_rebase((object_v -> callup_v), V, _),
%   findall(X, class_descendant(callup_v, X), List).

% test(class_same_or_descendant1,
%      [List == [callup_v, citizen_v, class_create_test_v, man_v]]
%     ) :-

%   findall(X, class_same_or_descendant(man_v, X), List0),
%   msort(List0, List).

% test(class_same_or_descendant2,
%      [List == [callup_v]]
%     ) :-

%   findall(X, class_same_or_descendant(callup_v, X), List).

% test(class_same_or_descendant3, [List == [callup_v]]) :-

%   obj_construct(tarjan_vertex_v, [], [], V),
%   obj_rebase((object_v -> callup_v), V, _),
%   findall(X, class_same_or_descendant(callup_v, X), List).

test(class_parent1, [Parent == man_v]) :-

   class_parent(citizen_v, Parent).

test(class_parent2,
     [L == [callup_v, class_create_test_v]]) :-

   findall(Desc, class_parent(Desc, citizen_v), LU),
   msort(LU, L).

test(class_parent3) :-

   findall(p(A, B), class_parent(A, B), L),
   length(L, N),
   assertion(N > 10).

test(eval_obj_expr,
     [[E1, E2, E3] =@= [HTTP_Result, WWW_Addr, Url]]
     ) :-

   Url = 'http://kogorta.dp.ua',
   obj_construct(www_address_v,
                 [http_request_url], [Url], WWW_Addr),
   obj_construct(http_result_v,
                 [www_address], [WWW_Addr], HTTP_Result),
   eval_obj_expr(HTTP_Result, E1),
   eval_obj_expr(HTTP_Result/www_address, E2),
   eval_obj_expr(HTTP_Result/www_address/http_request_url, E3).

test(obj_construct_with_evals1) :-

    obj_construct(citizen_v,
                  [functor, class, birthday],
                  [citizen_v, citizen_v, 1994], O1),
    obj_field(O1, class, Class1),
    assertion(Class1 == citizen_v),

    obj_construct(citizen_v,
                  [birthday, functor, class],
                  [1994, citizen_v, citizen_v], O2),
    obj_field(O2, class, Class2),
    assertion(Class2 == citizen_v),

    obj_construct(citizen_v,
                  [birthday, sex, functor, class],
                  [1994, man, citizen_v, callup_v], O3),
    obj_field(O3, class, Class3),
    assertion(Class3 == callup_v),

    obj_construct(citizen_v,
                  [functor, class, birthday, sex],
                  [citizen_v, callup_v, 1994, man], O4),
    obj_field(O4, class, Class4),
    assertion(Class4 == callup_v),

    obj_construct(citizen_v,
                  [functor, class, birthday, sex],
                  [X, Y, 1994, man], O5),
    obj_field(O5, class, Class5),
    assertion(Class5 == callup_v),
    assertion(X = citizen_v),
    assertion(Y = callup_v).

test(obj_construct_bug1) :-

   class_fields(man_v, Field_Names),
   obj_construct(man_v, Field_Names, Field_Names, Obj),
   Obj =.. [man_v, _|Field_Names2],

   assertion(Field_Names == Field_Names2).

test(obj_copy1) :-

   obj_construct(man_v, [], [], M1),
   obj_copy(M1, M2),
   obj_field(M1, name, 'Masha'),
   obj_field(M2, name, 'Vitya').

test(obj_copy2) :-

   new_http_user(U1),
   obj_copy(U1, U2),
   obj_field(U1, cookie_db_key, Key1),
   obj_field(U2, cookie_db_key, Key2),
   assertion(Key1 \= Key2).

test(obj_diff1,
     [Diff == [diff(name, 'Sergei', 'Artemiy')]]) :-

   obj_construct(man_v, [name, surname], ['Sergei', 'Lodyagin'], M1),
   obj_construct(man_v, [name, surname], ['Artemiy', 'Lodyagin'], M2),
   obj_diff(M1, M2, Diff).

test(obj_diff2,
     [Diff == [diff(name, 'Sergei', 'Artemiy')]]) :-

   obj_construct(man_v, [name, surname], ['Sergei', 'Lodyagin'], M1_0),
   obj_rebase((object_v -> db_object_v), M1_0, M1),
   obj_construct(man_v, [name, surname], ['Artemiy', 'Lodyagin'], M2),
   obj_diff(M1, M2, Diff).

% After some time it will always fails (because it depends
% on the current year).
test(obj_downcast1,
     [C1 =@= callup_v(Class_Id, 1994, _, _, _, _, _, man, _, _)]) :-

   obj_construct(citizen_v, [sex, birthday], [man, 1994], C0),
   obj_downcast(C0, C1),
   arg(1, C1, Class_Id).

test(obj_field1, [Flds == Vals]) :-

   class_fields(citizen_v, Flds),
   obj_construct(citizen_v, Flds, Flds, Obj),
   findall(Val, (obj_field(Obj, Fld, Val), member(Fld, Flds)), Vals).

test(obj_field2, [Flds3 == Flds4]) :-
% Each eval field must be evaluable only once

   class_fields(citizen_v, Flds),
   obj_construct(citizen_v, Flds, Flds, Obj),
   findall(Fld, obj_field(Obj, Fld, _), Flds2),
   sort(Flds2, Flds3),
   msort(Flds2, Flds4).

test(obj_field3, [Surname == 'Grisha']) :-

   obj_construct(man_v, [], [], Man),
   obj_field(Man, name, Name),
   obj_field(Man, surname, Name),
   Name = 'Grisha',
   obj_field(Man, surname, Surname).

test(obj_field_bug1, [fail]) :-

   obj_construct(citizen_v, [sex], [woman], Obj),
   obj_field(Obj, sex, man).

test(obj_is_descendant1, [List == [object_base_v, object_v]]) :-

   obj_construct(man_v, [], [], Man),
   findall(X, obj_is_descendant(Man, X), List0),
   msort(List0, List).

test(obj_is_descendant2) :-

   obj_construct(man_v, [], [], Man),
   \+ obj_is_descendant(Man, db_object_v),
   obj_rebase((object_v -> db_object_v), Man, Man2),
   obj_is_descendant(Man2, db_object_v).

test(obj_set_field1, [Surname =@= _]) :-

   obj_construct(man_v, [], [], Man),
   obj_set_field(Man, name, Name),
   obj_set_field(Man, surname, Name),
   Name = 'Grisha',
   obj_field(Man, surname, Surname).

test(obj_set_field2, [Surname =@= 'Grisha']) :-

   obj_construct(man_v, [name, surname], [Name, Name], Man),
   obj_set_field(Man, name, 'Grisha'),
   obj_field(Man, surname, Surname).

test(obj_key1) :-

   obj_construct(man_v, [sex, name], [man, 'Adam'], Man1),
   obj_key(Man1, Key1),
   assertion(Key1 == [name, surname]),
   obj_key_value(Man1, Key_Value1),
   assertion(Key_Value1 =@= ['Adam', _]),

   obj_construct(citizen_v,
                 [sex, surname, country],
                 [man, 'Mayakovsky', ['Soviet Union']],
                 Man2),
   obj_key(Man2, Key2),
   assertion(Key2 == [id]),
   obj_key_value(Man2, Key_Value2),
   assertion(Key_Value2 =@= [_]).

test(obj_key2) :-

   obj_construct(man_v, [sex, name], [man, 'Adam'], Man1_0),
   obj_rebase((object_v -> db_object_v), Man1_0, Man1),
   obj_key(Man1, Key1),
   assertion(Key1 == [name, surname]),
   obj_key_value(Man1, Key_Value1),
   assertion(Key_Value1 =@= ['Adam', _]),

   obj_construct(citizen_v,
                 [sex, surname, country],
                 [man, 'Mayakovsky', ['Soviet Union']],
                 Man2_0),
   obj_rebase((object_v -> db_object_v), Man2_0, Man2),
   obj_key(Man2, Key2),
   assertion(Key2 == [id]),
   obj_key_value(Man2, Key_Value2),
   assertion(Key_Value2 =@= [_]).

test(obj_list1,
     [List =@= [country = ['Soviet Union'],
                sex = man,
                surname = 'Mayakovsky']]
     ) :-

   obj_construct(citizen_v,
                 [sex, surname, country],
                 [man, 'Mayakovsky', ['Soviet Union']],
                 Man),
   obj_list(Man, List).

test(obj_list2, [List =@= []]) :-

   obj_construct(citizen_v, [], [], Man),
   obj_list(Man, List).

test(obj_parents1_1,
     [P = [citizen_v, man_v, object_v, object_base_v]]) :-

   obj_construct(citizen_v, [], [], V),
   obj_parents(V, P).

test(obj_parents2_1) :-

   obj_construct(citizen_v,
                 [sex, surname, country],
                 [man, 'Mayakovsky', ['Soviet Union']],
                 Man1),
   New_Parents_Order = [man_v, citizen_v, object_v, object_base_v],
   obj_parents(Man1, New_Parents_Order, Man2),
   obj_parents(Man1, P1),
   assertion(P1 == [citizen_v, man_v, object_v, object_base_v]),
   obj_parents(Man2, P2),
   assertion(P2 == New_Parents_Order),
   obj_list(Man1, L1),
   obj_list(Man2, L2),
   assertion(L1 == L2),
   obj_field(Man1, class, C1),
   obj_field(Man2, class, C2),
   obj_field(Man1, functor, F1),
   obj_field(Man2, functor, F2),
   assertion([F1, F2, C1, C2] == [citizen_v, man_v, callup_v, callup_v]).

test(obj_parents2_bug1, [error(use_rebase_to_insert_parents)]) :-

   obj_construct(man_v, [], [], M),
   obj_parents(M, [man_v, db_object_v, object_v, object_base_v], _).

test(obj_rebase1) :-

   obj_construct(http_request_headers_v, [], [], V1),
   obj_parents(V1, P1),
   assertion(P1 == [http_request_headers_v, http_headers_v,
                    object_v,object_base_v]),
   obj_rebase((http_headers_v -> http_response_headers_v),
              V1, V2),
   obj_parents(V2, P2),
   assertion(P2 == [http_request_headers_v,
                    http_response_headers_v,http_headers_v,
                    object_v,object_base_v]),
   obj_rebase((http_request_headers_v ->
               http_invalid_mixed_headers_v), V2, V3),
   obj_parents(V3, P3),
   assertion(P3 == [http_invalid_mixed_headers_v,
                    http_invalid_headers_v,
                    http_headers_v,
                    object_v,object_base_v]).

test(obj_rebase2_transitivity) :-

   obj_construct(citizen_v, [], [], M1),
   obj_rebase((object_v -> db_object_v), M1, M2),
   obj_rebase((man_v -> tarjan_vertex_v), M2, M3),
   obj_parents(M3, P3),
   assertion(P3 == [citizen_v, tarjan_vertex_v, db_object_v,
                    object_v, object_base_v]).

test(obj_rebase3_transitivity2) :-

   obj_construct(citizen_v, [], [], M1),
   obj_rebase((object_v -> db_object_v), M1, M2),
   obj_rebase((man_v -> tarjan_vertex_v), M2, M3),
   foreach(obj_field(M3, _, _), true).

test(obj_rebase_bug1) :-

   obj_construct(man_v, [sex, name], [man, 'Adam'], Obj1_0),
   obj_rebase((object_v -> db_object_v), Obj1_0, Obj1),

   obj_construct(man_v, [sex, name], [man, 'Adam'], Obj2_0),
   obj_rebase((object_v -> db_object_v), Obj2_0, Obj2),

   arg(1, Obj1, Class_Id1),
   arg(1, Obj2, Class_Id2),

   assertion(Class_Id1 =:= Class_Id2),

   obj_rebase((db_object_v -> object_v), Obj2, Obj3),

   arg(1, Obj2_0, Class_Id0),
   arg(1, Obj3, Class_Id3),
   assertion(Class_Id0 =:= Class_Id3),
   assertion(Obj2_0 == Obj3).

test(obj_rebase_bug2) :-

   obj_construct(citizen_v, [sex], [man], Obj1_0),
   obj_rebase((object_v -> db_object_v), Obj1_0, Obj1),

   obj_construct(citizen_v, [sex], [man], Obj2_0),
   obj_rebase((object_v -> db_object_v), Obj2_0, Obj2),

   arg(1, Obj1, Class_Id1),
   arg(1, Obj2, Class_Id2),

   assertion(Class_Id1 =:= Class_Id2),

   obj_rebase((db_object_v -> object_v), Obj2, Obj3),

   arg(1, Obj2_0, Class_Id0),
   arg(1, Obj3, Class_Id3),
   assertion(Class_Id0 =:= Class_Id3),
   assertion(Obj2_0 == Obj3).

test(obj_rebase_bug3_1) :-

   obj_construct(db_object_v, [], [], Obj1_0),
   obj_rebase((object_v -> db_object_v), Obj1_0, Obj1),

   obj_construct(db_object_v, [], [], Obj2_0),
   obj_rebase((object_v -> db_object_v), Obj2_0, Obj2),

   arg(1, Obj1, Class_Id1),
   arg(1, Obj2, Class_Id2),

   assertion(Class_Id1 =:= Class_Id2),

   obj_rebase((db_object_v -> object_v), Obj2, Obj3),

   arg(1, Obj2_0, Class_Id0),
   arg(1, Obj3, Class_Id3),
   assertion(Class_Id0 =\= Class_Id3),

   class_primary_id(object_v, Object_V_Id),
   assertion(Obj3 == object_v(Object_V_Id)).

test(obj_rebase_bug3_2) :-

   obj_construct(citizen_v, [], [], Obj1_0),
   obj_rebase((man_v -> citizen_v), Obj1_0, Obj1),

   obj_construct(citizen_v, [], [], Obj2_0),
   obj_rebase((object_v -> man_v), Obj2_0, Obj2),

   arg(1, Obj1, Class_Id1),
   arg(1, Obj2, Class_Id2),

   assertion(Class_Id1 =:= Class_Id2).

test(obj_rebase_bug4,
     [throws(error(cant_rebase_to_object_base_v,
                   context(obj_rebase/3, _)))]) :-

   obj_construct(citizen_v, [], [], Obj1_0),
   obj_rebase((citizen_v -> object_base_v), Obj1_0, Obj1),

   obj_construct(citizen_v, [], [], Obj2_0),
   obj_rebase((citizen_v -> object_base_v), Obj2_0, Obj2),

   arg(1, Obj1, Class_Id1),
   arg(1, Obj2, Class_Id2),

   assertion(Class_Id1 =:= Class_Id2),

   obj_rebase((object_base_v -> citizen_v), Obj2, Obj3),

   arg(1, Obj2_0, Class_Id0),
   arg(1, Obj3, Class_Id3),
   assertion(Class_Id0 =:= Class_Id3),
   assertion(Obj2_0 == Obj3).

test(obj_reset_fields1) :-

   obj_construct(man_v,
                 [sex, name, weight, height],
                 [man, 'Simeon', 63, 1.75], Man0),

   obj_reset_fields([name, height], Man0, Man1),
   obj_class_id(Man1, Class_Id),
   assertion(Man1 =@= man_v(Class_Id, _, _, man, _, 63)),

   obj_reset_fields([weight], Man1, Man2),
   assertion(Man2 =@= man_v(Class_Id, _, _, man, _, _)),

   obj_reset_fields([], Man2, Man3),
   assertion(Man3 =@= Man2).

test(obj_reset_fields2, [fail]) :-

   obj_construct(man_v,
                 [sex, name, weight, height],
                 [man, 'Simeon', 63, 1.75], Man0),

   obj_reset_fields([name, height, age], Man0, _).

test(obj_reset_fields_weak) :-

   obj_construct(man_v,
                 [sex, name, weight, height],
                 [man, 'Simeon', 63, 1.75], Man0),

   obj_reset_fields_weak([name, height, age], Man0, Man1),
   obj_class_id(Man1, Class_Id),
   assertion(Man1 =@= man_v(Class_Id, _, _, man, _, 63)).

test(obj_reset_fields_with_evals, [fail]) :-

   obj_construct(citizen_v, [sex], [man], O),
   obj_reset_fields([age], O, _).

test(obj_rewrite) :-

   obj_construct(man_v,
                 [name, height, weight],
                 ['Luda', 1.40, 99], Luda1),
   obj_rewrite(Luda1,
               [height, weight, name],
               [Old_Height, Old_Weight, Name],
               [1.44, 69, Name],
               Luda2),
   assertion([Old_Height, Old_Weight] =@= [1.40, 99]),
   obj_rewrite(Luda2,
               [height, weight, name],
               Luda2_Pars,
               [1.45, 64, _],
               Luda3),
   assertion(Luda2_Pars =@= [1.44, 69, 'Luda']),
   named_args_unify(Luda3, [height, weight, name], Luda3_Pars),
   assertion(Luda3_Pars =@= [1.45, 64, _]).

test(obj_rewrite_weak1,
     [throws(error(no_object_field(Luda1, country), _))]) :-

   obj_construct(man_v,
                 [name, height, weight],
                 ['Luda', 1.40, 99], Luda1),
   obj_rewrite(Luda1,
               [height, weight, name, country],
               _,
               [1.44, 69, _, 'UK'],
               _).

test(obj_rewrite_weak2,
     [[Old_Height, Old_Weight, Name, Old_Country]
     =@= [1.40, 99, 'Luda', _]]
     ) :-

   obj_construct(man_v,
                 [name, height, weight],
                 ['Luda', 1.40, 99], Luda1),
   obj_rewrite(Luda1, weak,
               [height, weight, name, country],
               [Old_Height, Old_Weight, Name, Old_Country],
               [1.44, 69, Name, 'UK'],
               _).

test(obj_rewrite_weak3, [fail]) :-

   obj_construct(man_v,
                 [name, height, weight],
                 ['Luda', 1.40, 99], Luda1),
   obj_rewrite(Luda1, fail,
               [height, weight, name, country],
               _,
               [1.44, 69, _, 'UK'],
               _).

test(obj_rewrite_with_evals1, [X == callup_v]) :-

   obj_construct(citizen_v, [sex, birthday], [man, 1994], O),
   obj_rewrite(O, [class], [X], [callup_v], _).

test(obj_rewrite_with_evals2, [fail]) :-

   obj_construct(citizen_v, [sex, birthday], [man, 1994], O),
   obj_rewrite(O, [class], [_], [citizen_v], _).

test(obj_rewrite_with_evals3, [X == callup_v]) :-

   obj_construct(citizen_v, [sex, birthday], [man, 1994], O),
   obj_rewrite(O, [class], [X], [X], _).

test(obj_rewrite_with_evals4) :-
% <NB> can't reset eval field, compare with test(obj_rewrite)

   obj_construct(citizen_v, [sex, birthday], [man, 1994], O),
   obj_rewrite(O, [class], [_], [_], _).

test(obj_sort_parents1,
     [P4 == [http_invalid_mixed_headers_v,
             http_invalid_headers_v,
             http_request_headers_v,
             http_response_headers_v,
             http_headers_v,
             object_v, object_base_v]]
     ) :-

   obj_construct(http_request_headers_v, [], [], V1),
   obj_rebase((http_headers_v -> http_response_headers_v),
              V1, V2),
   obj_rebase((http_headers_v -> http_invalid_mixed_headers_v),
              V2, V3),

   obj_sort_parents(V3, [http_invalid_bulk_headers_v,
                         http_invalid_mixed_headers_v,
                         http_invalid_headers_v,
                         http_request_headers_v,
                         http_response_headers_v,
                         http_headers_v,
                         tarjan_vertex_v,
                         db_object_v,
                         object_v, object_base_v], V4),
   obj_parents(V4, P4),
   functor(V4, F4, _),
   assertion(F4 == http_invalid_mixed_headers_v).

test(obj_sort_parents2,
     [throws(error(insufficient_class_order(Order,
                                            Orig_Order), _))]
     ) :-

   Order = [http_invalid_bulk_headers_v,
            http_invalid_mixed_headers_v,
            http_request_headers_v,
            http_response_headers_v,
            http_headers_v,
            tarjan_vertex_v,
            db_object_v,
            object_v, object_base_v],

   obj_construct(http_request_headers_v, [], [], V1),
   obj_rebase((http_headers_v -> http_response_headers_v),
              V1, V2),
   obj_rebase((http_headers_v -> http_invalid_mixed_headers_v),
              V2, V3),

   obj_parents(V3, Orig_Order),
   obj_sort_parents(V3, Order, _).

test(obj_sort_parents_bug1) :-

   new_http_user(HTTP_User),
   obj_rebase((object_v -> citizen_v),
              HTTP_User, U1),

   class_parents(http_user_v, HTTP_User_Parents),
   append([citizen_v, man_v], HTTP_User_Parents,
          Parents_Order),

   obj_sort_parents(U1, Parents_Order, HTTP_Citizen),
   % citizen_v -> man_v -> http_user_v -> ...object_base_v

   obj_copy(HTTP_Citizen, HTTP_Citizen_Copy),
   obj_field(HTTP_Citizen, cookie_db_key, Key1),
   obj_field(HTTP_Citizen_Copy, cookie_db_key, Key2),
   assertion(Key1 \= Key2).

test(class_fields) :-

   class_fields(object_base_v, Object_Base_V_Fields),
   assertion(Object_Base_V_Fields == []),

   class_fields_new(object_base_v, Object_Base_V_New_Fields),
   assertion(Object_Base_V_New_Fields == []),

   class_fields(object_v, Object_V_Fields),
   assertion(Object_V_Fields == []),

   class_fields_new(object_v, Object_V_New_Fields),
   assertion(Object_V_New_Fields == []),

   class_fields(man_v, Man_V_Fields),
   assertion(Man_V_Fields == [height, name, sex, surname, weight]),

   class_fields_new(man_v, Man_V_New_Fields),
   assertion(Man_V_New_Fields == [height, name, sex, surname,
                                  weight]),

   class_fields(citizen_v, Citizen_V_Fields),
   assertion(Citizen_V_Fields == [birthday, country, height, id,
                                  name, sex, surname, weight]),

   class_fields_new(citizen_v, Citizen_V_New_Fields),
   assertion(Citizen_V_New_Fields == [birthday, country, id]).

% After some time it will always fails (because it depends
% on the current year, see The Uranium Book).
test(eval_fields1, [Class == callup_v]) :-

   obj_construct(citizen_v, [sex, birthday], [man, 1994], C),
   obj_field(C, class, Class).

test(cleanup_obj_rebase, [blocked(transaction_bug), N1 =:= N2]) :-

   aggregate(count, A^B^C^(objects:class_id(A, B, C)), N1),
   catch((obj_construct(numeric_id_v, [], [], Obj1),
          obj_rebase((object_v -> citizen_v), Obj1, _)),
         E, true),
   E = error(EX, _), functor(EX, duplicate_field, _),
   aggregate(count, A^B^C^(objects:class_id(A, B, C)), N2).

test(eval_fields1) :-

   % man_v doesn't define class eval, so in this example
   % the eval from citizen_v is always used.

   obj_construct(citizen_v,
                 [sex, birthday], [man, 1994], C1),
   obj_field(C1, class, Cl1),
   obj_parents(C1,
               [man_v, citizen_v, object_v, object_base_v],
               C2),
   obj_field(C2, class, Cl2),
   assertion(Cl1 == callup_v),
   assertion(Cl2 == callup_v).

test(eval_fields2) :-

   obj_construct(callup_v,
                 [sex, birthday], [man, 1994], C1),
   obj_field(C1, class, Cl1),
   obj_rebase((citizen_v -> man_v), C1, C2),
   obj_parents(C2, P2),

   % for sure, citizen_v is not present
   assertion(P2 ==
            [callup_v, man_v, object_v, object_base_v]),

   obj_field(C2, class, Cl2),
   assertion(Cl1 == callup_v),
   assertion(Cl2 == man_v).

:- end_tests(v).

:- begin_tests(v).
:- use_module(u(v)).
:- use_module(u(internal/objects_i)).
:- use_module(u(http/v/http_user_v)).

test(class_create1) :-
   % test class_create/3 version

   current_prolog_flag(verbose, Old_Verbose),
   set_prolog_flag(verbose, silent),
   reload_all_classes,
   set_prolog_flag(verbose, Old_Verbose),

   class_create(class_create_test_v, citizen_v, [a, c, b]),
   obj_construct(class_create_test_v, [birthday], [1976], CCTO),
   class_fields(citizen_v, CF), sort(CF, CFS),
   class_fields(class_create_test_v, CCTF), sort(CCTF, CCTFS),
   class_fields_new(class_create_test_v, CCTFN),
   assertion(CF == CFS),
   assertion(CCTF = CCTFS),
   assertion(CCTFN == [a, b, c]),

   ord_subtract(CCTF, CF, New_Fields),
   assertion(New_Fields == CCTFN),

   obj_field(CCTO, age, Age),
   integer(Age),

   obj_key(CCTO, Key),
   assertion(Key == [id]).

test(class_create2) :-
   % test class_create/4 version

   current_prolog_flag(verbose, Old_Verbose),
   set_prolog_flag(verbose, silent),
   reload_all_classes,
   set_prolog_flag(verbose, Old_Verbose),

   class_create(class_create_test_v, citizen_v, [a, c, b],
                [birthday, a]),
   obj_construct(class_create_test_v, [birthday], [1976], CCTO),
   class_fields(citizen_v, CF), sort(CF, CFS),
   class_fields(class_create_test_v, CCTF), sort(CCTF, CCTFS),
   class_fields_new(class_create_test_v, CCTFN),
   assertion(CF == CFS),
   assertion(CCTF = CCTFS),
   assertion(CCTFN == [a, b, c]),

   ord_subtract(CCTF, CF, New_Fields),
   assertion(New_Fields == CCTFN),

   obj_field(CCTO, age, Age),
   integer(Age),

   obj_key(CCTO, Key),
   assertion(Key == [a, birthday]).

test(class_create_feature1) :-
   % It is a strange feature

   current_prolog_flag(verbose, Old_Verbose),
   set_prolog_flag(verbose, silent),
   reload_all_classes,
   set_prolog_flag(verbose, Old_Verbose),

   class_create(class_create_test_v, citizen_v, [a, c, b], []),
   obj_construct(class_create_test_v, [birthday], [1976], CCTO),
   obj_key(CCTO, Key),
   assertion(Key == []).

% test(class_descendant1,
%      [List == [callup_v, citizen_v, class_create_test_v]]
%     ) :-

%   findall(X, class_descendant(man_v, X), List0),
%   msort(List0, List).

% test(class_descendant2, [List == []]) :-

%   findall(X, class_descendant(callup_v, X), List).

% test(class_descendant3, [List == []]) :-

%   obj_construct(tarjan_vertex_v, [], [], V),
%   obj_rebase((object_v -> callup_v), V, _),
%   findall(X, class_descendant(callup_v, X), List).

% test(class_same_or_descendant1,
%      [List == [callup_v, citizen_v, class_create_test_v, man_v]]
%     ) :-

%   findall(X, class_same_or_descendant(man_v, X), List0),
%   msort(List0, List).

% test(class_same_or_descendant2,
%      [List == [callup_v]]
%     ) :-

%   findall(X, class_same_or_descendant(callup_v, X), List).

% test(class_same_or_descendant3, [List == [callup_v]]) :-

%   obj_construct(tarjan_vertex_v, [], [], V),
%   obj_rebase((object_v -> callup_v), V, _),
%   findall(X, class_same_or_descendant(callup_v, X), List).

test(class_parent1, [Parent == man_v]) :-

   class_parent(citizen_v, Parent).

test(class_parent2,
     [L == [callup_v, class_create_test_v]]) :-

   findall(Desc, class_parent(Desc, citizen_v), LU),
   msort(LU, L).

test(class_parent3) :-

   findall(p(A, B), class_parent(A, B), L),
   length(L, N),
   assertion(N > 10).

test(eval_obj_expr,
     [[E1, E2, E3] =@= [HTTP_Result, WWW_Addr, Url]]
     ) :-

   Url = 'http://kogorta.dp.ua',
   obj_construct(www_address_v,
                 [http_request_url], [Url], WWW_Addr),
   obj_construct(http_result_v,
                 [www_address], [WWW_Addr], HTTP_Result),
   eval_obj_expr(HTTP_Result, E1),
   eval_obj_expr(HTTP_Result/www_address, E2),
   eval_obj_expr(HTTP_Result/www_address/http_request_url, E3).

test(obj_construct_with_evals1) :-

    obj_construct(citizen_v,
                  [functor, class, birthday],
                  [citizen_v, citizen_v, 1994], O1),
    obj_field(O1, class, Class1),
    assertion(Class1 == citizen_v),

    obj_construct(citizen_v,
                  [birthday, functor, class],
                  [1994, citizen_v, citizen_v], O2),
    obj_field(O2, class, Class2),
    assertion(Class2 == citizen_v),

    obj_construct(citizen_v,
                  [birthday, sex, functor, class],
                  [1994, man, citizen_v, callup_v], O3),
    obj_field(O3, class, Class3),
    assertion(Class3 == callup_v),

    obj_construct(citizen_v,
                  [functor, class, birthday, sex],
                  [citizen_v, callup_v, 1994, man], O4),
    obj_field(O4, class, Class4),
    assertion(Class4 == callup_v),

    obj_construct(citizen_v,
                  [functor, class, birthday, sex],
                  [X, Y, 1994, man], O5),
    obj_field(O5, class, Class5),
    assertion(Class5 == callup_v),
    assertion(X = citizen_v),
    assertion(Y = callup_v).

test(obj_construct_bug1) :-

   class_fields(man_v, Field_Names),
   obj_construct(man_v, Field_Names, Field_Names, Obj),
   Obj =.. [man_v, _|Field_Names2],

   assertion(Field_Names == Field_Names2).

test(obj_copy1) :-

   obj_construct(man_v, [], [], M1),
   obj_copy(M1, M2),
   obj_field(M1, name, 'Masha'),
   obj_field(M2, name, 'Vitya').

test(obj_copy2) :-

   new_http_user(U1),
   obj_copy(U1, U2),
   obj_field(U1, cookie_db_key, Key1),
   obj_field(U2, cookie_db_key, Key2),
   assertion(Key1 \= Key2).

test(obj_diff1,
     [Diff == [diff(name, 'Sergei', 'Artemiy')]]) :-

   obj_construct(man_v, [name, surname], ['Sergei', 'Lodyagin'], M1),
   obj_construct(man_v, [name, surname], ['Artemiy', 'Lodyagin'], M2),
   obj_diff(M1, M2, Diff).

test(obj_diff2,
     [Diff == [diff(name, 'Sergei', 'Artemiy')]]) :-

   obj_construct(man_v, [name, surname], ['Sergei', 'Lodyagin'], M1_0),
   obj_rebase((object_v -> db_object_v), M1_0, M1),
   obj_construct(man_v, [name, surname], ['Artemiy', 'Lodyagin'], M2),
   obj_diff(M1, M2, Diff).

% After some time it will always fails (because it depends
% on the current year).
test(obj_downcast1,
     [C1 =@= callup_v(Class_Id, 1994, _, _, _, _, _, man, _, _)]) :-

   obj_construct(citizen_v, [sex, birthday], [man, 1994], C0),
   obj_downcast(C0, C1),
   arg(1, C1, Class_Id).

test(obj_field1, [Flds == Vals]) :-

   class_fields(citizen_v, Flds),
   obj_construct(citizen_v, Flds, Flds, Obj),
   findall(Val, (obj_field(Obj, Fld, Val), member(Fld, Flds)), Vals).

test(obj_field2, [Flds3 == Flds4]) :-
% Each eval field must be evaluable only once

   class_fields(citizen_v, Flds),
   obj_construct(citizen_v, Flds, Flds, Obj),
   findall(Fld, obj_field(Obj, Fld, _), Flds2),
   sort(Flds2, Flds3),
   msort(Flds2, Flds4).

test(obj_field3, [Surname == 'Grisha']) :-

   obj_construct(man_v, [], [], Man),
   obj_field(Man, name, Name),
   obj_field(Man, surname, Name),
   Name = 'Grisha',
   obj_field(Man, surname, Surname).

test(obj_field_bug1, [fail]) :-

   obj_construct(citizen_v, [sex], [woman], Obj),
   obj_field(Obj, sex, man).

test(obj_is_descendant1, [List == [object_base_v, object_v]]) :-

   obj_construct(man_v, [], [], Man),
   findall(X, obj_is_descendant(Man, X), List0),
   msort(List0, List).

test(obj_is_descendant2) :-

   obj_construct(man_v, [], [], Man),
   \+ obj_is_descendant(Man, db_object_v),
   obj_rebase((object_v -> db_object_v), Man, Man2),
   obj_is_descendant(Man2, db_object_v).

test(obj_set_field1, [Surname =@= _]) :-

   obj_construct(man_v, [], [], Man),
   obj_set_field(Man, name, Name),
   obj_set_field(Man, surname, Name),
   Name = 'Grisha',
   obj_field(Man, surname, Surname).

test(obj_set_field2, [Surname =@= 'Grisha']) :-

   obj_construct(man_v, [name, surname], [Name, Name], Man),
   obj_set_field(Man, name, 'Grisha'),
   obj_field(Man, surname, Surname).

test(obj_key1) :-

   obj_construct(man_v, [sex, name], [man, 'Adam'], Man1),
   obj_key(Man1, Key1),
   assertion(Key1 == [name, surname]),
   obj_key_value(Man1, Key_Value1),
   assertion(Key_Value1 =@= ['Adam', _]),

   obj_construct(citizen_v,
                 [sex, surname, country],
                 [man, 'Mayakovsky', ['Soviet Union']],
                 Man2),
   obj_key(Man2, Key2),
   assertion(Key2 == [id]),
   obj_key_value(Man2, Key_Value2),
   assertion(Key_Value2 =@= [_]).

test(obj_key2) :-

   obj_construct(man_v, [sex, name], [man, 'Adam'], Man1_0),
   obj_rebase((object_v -> db_object_v), Man1_0, Man1),
   obj_key(Man1, Key1),
   assertion(Key1 == [name, surname]),
   obj_key_value(Man1, Key_Value1),
   assertion(Key_Value1 =@= ['Adam', _]),

   obj_construct(citizen_v,
                 [sex, surname, country],
                 [man, 'Mayakovsky', ['Soviet Union']],
                 Man2_0),
   obj_rebase((object_v -> db_object_v), Man2_0, Man2),
   obj_key(Man2, Key2),
   assertion(Key2 == [id]),
   obj_key_value(Man2, Key_Value2),
   assertion(Key_Value2 =@= [_]).

test(obj_list1,
     [List =@= [country = ['Soviet Union'],
                sex = man,
                surname = 'Mayakovsky']]
     ) :-

   obj_construct(citizen_v,
                 [sex, surname, country],
                 [man, 'Mayakovsky', ['Soviet Union']],
                 Man),
   obj_list(Man, List).

test(obj_list2, [List =@= []]) :-

   obj_construct(citizen_v, [], [], Man),
   obj_list(Man, List).

test(obj_parents1_1,
     [P = [citizen_v, man_v, object_v, object_base_v]]) :-

   obj_construct(citizen_v, [], [], V),
   obj_parents(V, P).

test(obj_parents2_1) :-

   obj_construct(citizen_v,
                 [sex, surname, country],
                 [man, 'Mayakovsky', ['Soviet Union']],
                 Man1),
   New_Parents_Order = [man_v, citizen_v, object_v, object_base_v],
   obj_parents(Man1, New_Parents_Order, Man2),
   obj_parents(Man1, P1),
   assertion(P1 == [citizen_v, man_v, object_v, object_base_v]),
   obj_parents(Man2, P2),
   assertion(P2 == New_Parents_Order),
   obj_list(Man1, L1),
   obj_list(Man2, L2),
   assertion(L1 == L2),
   obj_field(Man1, class, C1),
   obj_field(Man2, class, C2),
   obj_field(Man1, functor, F1),
   obj_field(Man2, functor, F2),
   assertion([F1, F2, C1, C2] == [citizen_v, man_v, callup_v, callup_v]).

test(obj_rebase1) :-

   obj_construct(http_request_headers_v, [], [], V1),
   obj_parents(V1, P1),
   assertion(P1 == [http_request_headers_v, http_headers_v,
                    object_v,object_base_v]),
   obj_rebase((http_headers_v -> http_response_headers_v),
              V1, V2),
   obj_parents(V2, P2),
   assertion(P2 == [http_request_headers_v,
                    http_response_headers_v,http_headers_v,
                    object_v,object_base_v]),
   obj_rebase((http_request_headers_v ->
               http_invalid_mixed_headers_v), V2, V3),
   obj_parents(V3, P3),
   assertion(P3 == [http_invalid_mixed_headers_v,
                    http_invalid_headers_v,
                    http_headers_v,
                    object_v,object_base_v]).

test(obj_rebase2_transitivity) :-

   obj_construct(citizen_v, [], [], M1),
   obj_rebase((object_v -> db_object_v), M1, M2),
   obj_rebase((man_v -> tarjan_vertex_v), M2, M3),
   obj_parents(M3, P3),
   assertion(P3 == [citizen_v, tarjan_vertex_v, db_object_v,
                    object_v, object_base_v]).

test(obj_rebase_bug1) :-

   obj_construct(man_v, [sex, name], [man, 'Adam'], Obj1_0),
   obj_rebase((object_v -> db_object_v), Obj1_0, Obj1),

   obj_construct(man_v, [sex, name], [man, 'Adam'], Obj2_0),
   obj_rebase((object_v -> db_object_v), Obj2_0, Obj2),

   arg(1, Obj1, Class_Id1),
   arg(1, Obj2, Class_Id2),

   assertion(Class_Id1 =:= Class_Id2),

   obj_rebase((db_object_v -> object_v), Obj2, Obj3),

   arg(1, Obj2_0, Class_Id0),
   arg(1, Obj3, Class_Id3),
   assertion(Class_Id0 =:= Class_Id3),
   assertion(Obj2_0 == Obj3).

test(obj_rebase_bug2) :-

   obj_construct(citizen_v, [sex], [man], Obj1_0),
   obj_rebase((object_v -> db_object_v), Obj1_0, Obj1),

   obj_construct(citizen_v, [sex], [man], Obj2_0),
   obj_rebase((object_v -> db_object_v), Obj2_0, Obj2),

   arg(1, Obj1, Class_Id1),
   arg(1, Obj2, Class_Id2),

   assertion(Class_Id1 =:= Class_Id2),

   obj_rebase((db_object_v -> object_v), Obj2, Obj3),

   arg(1, Obj2_0, Class_Id0),
   arg(1, Obj3, Class_Id3),
   assertion(Class_Id0 =:= Class_Id3),
   assertion(Obj2_0 == Obj3).

test(obj_rebase_bug3_1) :-

   obj_construct(db_object_v, [], [], Obj1_0),
   obj_rebase((object_v -> db_object_v), Obj1_0, Obj1),

   obj_construct(db_object_v, [], [], Obj2_0),
   obj_rebase((object_v -> db_object_v), Obj2_0, Obj2),

   arg(1, Obj1, Class_Id1),
   arg(1, Obj2, Class_Id2),

   assertion(Class_Id1 =:= Class_Id2),

   obj_rebase((db_object_v -> object_v), Obj2, Obj3),

   arg(1, Obj2_0, Class_Id0),
   arg(1, Obj3, Class_Id3),
   assertion(Class_Id0 =\= Class_Id3),

   class_primary_id(object_v, Object_V_Id),
   assertion(Obj3 == object_v(Object_V_Id)).

test(obj_rebase_bug3_2) :-

   obj_construct(citizen_v, [], [], Obj1_0),
   obj_rebase((man_v -> citizen_v), Obj1_0, Obj1),

   obj_construct(citizen_v, [], [], Obj2_0),
   obj_rebase((object_v -> man_v), Obj2_0, Obj2),

   arg(1, Obj1, Class_Id1),
   arg(1, Obj2, Class_Id2),

   assertion(Class_Id1 =:= Class_Id2).

test(obj_rebase_bug4,
     [throws(error(cant_rebase_to_object_base_v,
                   context(obj_rebase/3, _)))]) :-

   obj_construct(citizen_v, [], [], Obj1_0),
   obj_rebase((citizen_v -> object_base_v), Obj1_0, Obj1),

   obj_construct(citizen_v, [], [], Obj2_0),
   obj_rebase((citizen_v -> object_base_v), Obj2_0, Obj2),

   arg(1, Obj1, Class_Id1),
   arg(1, Obj2, Class_Id2),

   assertion(Class_Id1 =:= Class_Id2),

   obj_rebase((object_base_v -> citizen_v), Obj2, Obj3),

   arg(1, Obj2_0, Class_Id0),
   arg(1, Obj3, Class_Id3),
   assertion(Class_Id0 =:= Class_Id3),
   assertion(Obj2_0 == Obj3).

test(obj_reset_fields1) :-

   obj_construct(man_v,
                 [sex, name, weight, height],
                 [man, 'Simeon', 63, 1.75], Man0),

   obj_reset_fields([name, height], Man0, Man1),
   obj_class_id(Man1, Class_Id),
   assertion(Man1 =@= man_v(Class_Id, _, _, man, _, 63)),

   obj_reset_fields([weight], Man1, Man2),
   assertion(Man2 =@= man_v(Class_Id, _, _, man, _, _)),

   obj_reset_fields([], Man2, Man3),
   assertion(Man3 =@= Man2).

test(obj_reset_fields2, [fail]) :-

   obj_construct(man_v,
                 [sex, name, weight, height],
                 [man, 'Simeon', 63, 1.75], Man0),

   obj_reset_fields([name, height, age], Man0, _).

test(obj_reset_fields_weak) :-

   obj_construct(man_v,
                 [sex, name, weight, height],
                 [man, 'Simeon', 63, 1.75], Man0),

   obj_reset_fields_weak([name, height, age], Man0, Man1),
   obj_class_id(Man1, Class_Id),
   assertion(Man1 =@= man_v(Class_Id, _, _, man, _, 63)).

test(obj_reset_fields_with_evals, [fail]) :-

   obj_construct(citizen_v, [sex], [man], O),
   obj_reset_fields([age], O, _).

test(obj_rewrite) :-

   obj_construct(man_v,
                 [name, height, weight],
                 ['Luda', 1.40, 99], Luda1),
   obj_rewrite(Luda1,
               [height, weight, name],
               [Old_Height, Old_Weight, Name],
               [1.44, 69, Name],
               Luda2),
   assertion([Old_Height, Old_Weight] =@= [1.40, 99]),
   obj_rewrite(Luda2,
               [height, weight, name],
               Luda2_Pars,
               [1.45, 64, _],
               Luda3),
   assertion(Luda2_Pars =@= [1.44, 69, 'Luda']),
   named_args_unify(Luda3, [height, weight, name], Luda3_Pars),
   assertion(Luda3_Pars =@= [1.45, 64, _]).

test(obj_rewrite_weak1,
     [throws(error(no_object_field(Luda1, country), _))]) :-

   obj_construct(man_v,
                 [name, height, weight],
                 ['Luda', 1.40, 99], Luda1),
   obj_rewrite(Luda1,
               [height, weight, name, country],
               _,
               [1.44, 69, _, 'UK'],
               _).

test(obj_rewrite_weak2,
     [[Old_Height, Old_Weight, Name, Old_Country]
     =@= [1.40, 99, 'Luda', _]]
     ) :-

   obj_construct(man_v,
                 [name, height, weight],
                 ['Luda', 1.40, 99], Luda1),
   obj_rewrite(Luda1, weak,
               [height, weight, name, country],
               [Old_Height, Old_Weight, Name, Old_Country],
               [1.44, 69, Name, 'UK'],
               _).

test(obj_rewrite_weak3, [fail]) :-

   obj_construct(man_v,
                 [name, height, weight],
                 ['Luda', 1.40, 99], Luda1),
   obj_rewrite(Luda1, fail,
               [height, weight, name, country],
               _,
               [1.44, 69, _, 'UK'],
               _).

test(obj_rewrite_with_evals1, [X == callup_v]) :-

   obj_construct(citizen_v, [sex, birthday], [man, 1994], O),
   obj_rewrite(O, [class], [X], [callup_v], _).

test(obj_rewrite_with_evals2, [fail]) :-

   obj_construct(citizen_v, [sex, birthday], [man, 1994], O),
   obj_rewrite(O, [class], [_], [citizen_v], _).

test(obj_rewrite_with_evals3, [X == callup_v]) :-

   obj_construct(citizen_v, [sex, birthday], [man, 1994], O),
   obj_rewrite(O, [class], [X], [X], _).

test(obj_rewrite_with_evals4) :-
% <NB> can't reset eval field, compare with test(obj_rewrite)

   obj_construct(citizen_v, [sex, birthday], [man, 1994], O),
   obj_rewrite(O, [class], [_], [_], _).

test(obj_sort_parents1,
     [P4 == [http_invalid_mixed_headers_v,
             http_invalid_headers_v,
             http_request_headers_v,
             http_response_headers_v,
             http_headers_v,
             object_v, object_base_v]]
     ) :-

   obj_construct(http_request_headers_v, [], [], V1),
   obj_rebase((http_headers_v -> http_response_headers_v),
              V1, V2),
   obj_rebase((http_headers_v -> http_invalid_mixed_headers_v),
              V2, V3),

   obj_sort_parents(V3, [http_invalid_bulk_headers_v,
                         http_invalid_mixed_headers_v,
                         http_invalid_headers_v,
                         http_request_headers_v,
                         http_response_headers_v,
                         http_headers_v,
                         tarjan_vertex_v,
                         db_object_v,
                         object_v, object_base_v], V4),
   obj_parents(V4, P4),
   functor(V4, F4, _),
   assertion(F4 == http_invalid_mixed_headers_v).

test(obj_sort_parents2,
     [throws(error(insufficient_class_order(Order,
                                            Orig_Order), _))]
     ) :-

   Order = [http_invalid_bulk_headers_v,
            http_invalid_mixed_headers_v,
            http_request_headers_v,
            http_response_headers_v,
            http_headers_v,
            tarjan_vertex_v,
            db_object_v,
            object_v, object_base_v],

   obj_construct(http_request_headers_v, [], [], V1),
   obj_rebase((http_headers_v -> http_response_headers_v),
              V1, V2),
   obj_rebase((http_headers_v -> http_invalid_mixed_headers_v),
              V2, V3),

   obj_parents(V3, Orig_Order),
   obj_sort_parents(V3, Order, _).

test(obj_sort_parents_bug1) :-

   new_http_user(HTTP_User),
   obj_rebase((object_v -> citizen_v),
              HTTP_User, U1),

   class_parents(http_user_v, HTTP_User_Parents),
   append([citizen_v, man_v], HTTP_User_Parents,
          Parents_Order),

   obj_sort_parents(U1, Parents_Order, HTTP_Citizen),
   % citizen_v -> man_v -> http_user_v -> ...object_base_v

   obj_copy(HTTP_Citizen, HTTP_Citizen_Copy),
   obj_field(HTTP_Citizen, cookie_db_key, Key1),
   obj_field(HTTP_Citizen_Copy, cookie_db_key, Key2),
   assertion(Key1 \= Key2).

test(class_fields) :-

   class_fields(object_base_v, Object_Base_V_Fields),
   assertion(Object_Base_V_Fields == []),

   class_fields_new(object_base_v, Object_Base_V_New_Fields),
   assertion(Object_Base_V_New_Fields == []),

   class_fields(object_v, Object_V_Fields),
   assertion(Object_V_Fields == []),

   class_fields_new(object_v, Object_V_New_Fields),
   assertion(Object_V_New_Fields == []),

   class_fields(man_v, Man_V_Fields),
   assertion(Man_V_Fields == [height, name, sex, surname, weight]),

   class_fields_new(man_v, Man_V_New_Fields),
   assertion(Man_V_New_Fields == [height, name, sex, surname,
                                  weight]),

   class_fields(citizen_v, Citizen_V_Fields),
   assertion(Citizen_V_Fields == [birthday, country, height, id,
                                  name, sex, surname, weight]),

   class_fields_new(citizen_v, Citizen_V_New_Fields),
   assertion(Citizen_V_New_Fields == [birthday, country, id]).

% After some time it will always fails (because it depends
% on the current year, see The Uranium Book).
test(eval_fields1, [Class == callup_v]) :-

   obj_construct(citizen_v, [sex, birthday], [man, 1994], C),
   obj_field(C, class, Class).

test(cleanup_obj_rebase, [blocked(transaction_bug), N1 =:= N2]) :-

   aggregate(count, A^B^C^(objects:class_id(A, B, C)), N1),
   catch((obj_construct(numeric_id_v, [], [], Obj1),
          obj_rebase((object_v -> citizen_v), Obj1, _)),
         E, true),
   E = error(EX, _), functor(EX, duplicate_field, _),
   aggregate(count, A^B^C^(objects:class_id(A, B, C)), N2).

test(eval_fields1) :-

   % man_v doesn't define class eval, so in this example
   % the eval from citizen_v is always used.

   obj_construct(citizen_v,
                 [sex, birthday], [man, 1994], C1),
   obj_field(C1, class, Cl1),
   obj_parents(C1,
               [man_v, citizen_v, object_v, object_base_v],
               C2),
   obj_field(C2, class, Cl2),
   assertion(Cl1 == callup_v),
   assertion(Cl2 == callup_v).

test(eval_fields2) :-

   obj_construct(callup_v,
                 [sex, birthday], [man, 1994], C1),
   obj_field(C1, class, Cl1),
   obj_rebase((citizen_v -> man_v), C1, C2),
   obj_parents(C2, P2),

   % for sure, citizen_v is not present
   assertion(P2 ==
            [callup_v, man_v, object_v, object_base_v]),

   obj_field(C2, class, Cl2),
   assertion(Cl1 == callup_v),
   assertion(Cl2 == man_v).

:- end_tests(v).