Commit 38540a23 authored by Arshia Cont's avatar Arshia Cont
Browse files

Stroppa Lib: Starting modularization of HarmLib

parent 9ca4f603
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>13F34</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>antescofo~</string>
<key>CFBundleIdentifier</key>
<string>com.cycling74.antescofo-</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.1.1</string>
<key>CFBundleLongVersionString</key>
<string>antescofo~ 6.1.0, Copyright 2013 Cycling '74</string>
<key>CFBundlePackageType</key>
<string>iLaX</string>
<key>CFBundleShortVersionString</key>
<string>6.1.0</string>
<key>CFBundleSignature</key>
<string>max2</string>
<key>CFBundleVersion</key>
<string>6.1.0</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>6A317</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>13F26</string>
<key>DTSDKName</key>
<string>macosx10.9</string>
<key>DTXcode</key>
<string>0600</string>
<key>DTXcodeBuild</key>
<string>6A317</string>
</dict>
</plist>
@global $p1, $p2, $global, $y, $q1, $q2
@proc_def ::P($id) {
@local $x
$x := 0
whenever ($x == $x)
{
print "at " $NOW "process " $id ": variable $x set to " $x
$global := $x
}
}
$p1 := ::P("toto")
$p2 := ::P("tutu")
$y := 0
1
$p1.$x := 33
@assert 33 == $p1.$x
@assert 33 == $global
1
$p2.$x := 66
@assert 66 == $p2.$x
@assert 66 == $global
@assert 33 == $p1.$x
1
$p1.$x := $p2.$x - 22
$p1.$x := $p1.$x
@assert 44 == $p1.$x
@assert 44 == $global
@assert 44 == $p1.$x
@assert 66 == $p2.$x
1
$p1.$y := 77
@assert 77 == $y
1
$y := 11
@assert 11 == $p1.$y
@assert 11 == $p2.$y
Group G1 {
@local $y
$y := 22
$q1 := ::P("titi")
whenever ($y == $y)
{
print "G1 " $NOW " variable $y set to " $y
$global := $y
}
}
$tab := [55, 1, 2, 3]
Group G2 {
@local $y
$y := $tab
$q2 := ::P("titi")
whenever ($y == $y)
{
print "G2 " $NOW " variable $y set to " $y
$global := $y
}
}
1
$q1.$x := 88
@assert 88 == $q1.$x
@assert 88 == $global
1
@assert 22 == $q1.$y
@assert 55 == $q2.$y[0]
1
$q1.$y := 99
@assert 99 == $q1.$y
@assert 99 == $global
@assert [55, 1, 2, 3] == $q2.$y
1
let $q2.$y[0] := 111
@assert 111 == $q2.$y[0]
// Attention : l'affectation n'a pas déclenché le whenever car
// on n'a affecté qu'un des éléments de $y, pas la variable $y.
@assert 99 == $global
@assert $tab == [111, 1, 2, 3]
@assert 99 == $q1.$y
1
print "--------------- more complex accesses ----------------"
$bad_happen := false
@proc_def ::PPP($x)
{
@local $tab
$tab := [ $x | ($x + 1) ]
Loop L 1 {
// print PPP $x
@assert !$bad_happen
} until ($tab[$x] != $x)
}
$nb := 100
$ttt := [ ::PPP($i) | $i in $nb ]
2
forall $i in $nb
{
@assert $ttt[$i].$tab[$i] == $i
}
forall $i in $nb
{
let $ttt[$i].$tab[$i] := 11 + $i
}
2
$bad_happen := true
1
print "--------------- accesses in a labeled bloc ----------------"
$x := 666
group LG1
{
$exe_lg1 := $MYSELF
@local $x
$x := 1
whenever ($x) { print LG1 $x }
}
$exe_lg2 := {
group LG2
{
@local $x
$x := 2
whenever ($x) { print LG2 $x }
}
}
1
@assert 1 == (LG1::$x)
@assert 2 == (LG2::$x)
1
$exe_lg1.$x := 11
$exe_lg2.$x := 22
1
@assert 11 == (LG1::$x)
@assert 22 == (LG2::$x)
1
print DONE DONE
$t1 := [0, 0, 0, 0]
$t2 := [1, 1.2, 1.4, 1.6]
$t3 := [-1, -.8, -.6, -.4]
$t4 := [2, 2.2, 2.4, 2.6]
$t5 := [-2, -1.8, -1.6, -1.4]
Curve CC
@grain 0.1,
@action { @assert ($zzz[0] == $a) && ($zzz[3] == $b) }
{
$zzz, $a, $b
{
{ $t1 ($t1[0]) ($t1[3]) } "sine_in_out"
1 { $t2 ($t2[0]) ($t2[3]) } "sine_in_out"
2 { $t3 ($t3[0]) ($t3[3]) } "sine_in_out"
3 { $t4 ($t4[0]) ($t4[3]) } "sine_in_out"
4 { $t5 ($t5[0]) ($t5[3]) } "sine_in_out"
}
}
// -----------------------------------
// pas d'assert. Juste pour vérifier que ces types existent bien.
$type := [
[ "linear_in",
"linear_out",
"linear_in_out" ],
[ "back_in",
"back_out",
"back_in_out" ],
[ "bounce_in",
"bounce_out",
"bounce_in_out" ],
[ "cubic_in",
"cubic_out",
"cubic_in_out" ],
[ "circ_in",
"circ_out",
"circ_in_out" ],
[ "elastic_in",
"elastic_out",
"elastic_in_out" ],
[ "exp_in",
"exp_out",
"exp_in_out" ],
[ "quad_in",
"quad_out",
"quad_in_out" ],
[ "quart_in",
"quart_out",
"quart_in_out" ],
[ "quint_in",
"quint_out",
"quint_in_out" ],
[ "sine_in",
"sine_out",
"sine_in_out" ]
]
$cpt := 0
forall $t in $type
{
@local 500:$y, $nim, $t
print $t
$nim := NIM{ 0 0, 1 1 $t }
curve player
@grain := 0.01
@action = { $y := $nim($x) }
{
$x { { 0 } 1 { 1 } }
}
1.1
$t0 := @explode($t[0])
$t1 := [ $t0[$i] | $i in (@size($t0) - 3) ]
$name := @reduce(@+, $t1)
// $z := @gnuplot($name, @tab_history_date($y), @tab_history($y))
$cpt := $cpt + 1
}
NOTE C4 12 EVENT1
"print" 1
$grain05 := 0
$ampg1t := 0
GROUP tutti
{
@local $grain05, $ampg1t
$grain05 := 0.05
$ampg1t := 0.0
Loop L 0.1 {
$grain05 := 0.01 + 0.05 * @rand(1.0)
} during [1/6 + 4/6 + 7/2 + 2 + 5]
GROUP tuttiaig {
curve ampg1t
@Grain := $grain05 s,
@Action := { @assert ($ampg1t >= 0) && ($ampg1t <= 0.5) }
{ $ampg1t
{ { 0. } @type "quad"
1/6 { 0.5 } @type "cubic_out"
4/6 { 0.25 }
7/2 { 0.05 } @type "quad_in_out"
2 { 0.4 } @type "quad"
5 { 0. }
}
}
}
12 @assert 0 == $ampg1t
}
Loop Check 0.01 {
@assert 0 == $grain05
@assert 0 == $ampg1t
} during [1/6 + 4/6 + 7/2 + 2 + 5]
NOTE C4 1 EVENT2
print DONE DONE
$i := 0;
$labels := [ "label_1", "label_2", "label_3",
"label_4", "label_6", "label_7" ]
whenever ($LAST_EVENT_LABEL)
{
@assert $labels[$i] == $LAST_EVENT_LABEL
$i := $i + 1
}
Note C4 1 label_1
Note C4 1 label_2
Note C4 1 label_3
Note C4 1 label_4
Note C4 1
Note C4 1 label_6
Note C4 1 label_7
print DONE DONE
Note C4 1/2
@assert 1 < 2
@assert 1 <= 2
@assert 1 <= 1
@assert 2 > 1
@assert 1 <= 2
@assert 1 >= 1
@assert 1.1 < 2.2
@assert 1.2 <= 2.1
@assert 1.0 <= 1.0
@assert 2.1 > 1.111
@assert 1.2 <= 2.0
@assert 1.3 >= 1.3
@assert 1 < 2.2
@assert 1 <= 2.1
@assert 1 <= 1.0
@assert 2 > 1.111
@assert 1 >= 0.99
@assert 1 <= 1.3
@assert 1.1 < 2
@assert 1.2 <= 2
@assert 1.0 <= 1
@assert 2.1 > 1
@assert 1.2 <= 2
@assert 1.3 >= 1
// avec un négatif
@assert -1 < 2
@assert -1 <= 2
@assert -1 <= 1
@assert 2 > -1
@assert 1 >= -2
@assert -1 >= -1
@assert -1.1 < 2.2
@assert -1.2 <= 2.1
@assert -1.0 <= 1.0
@assert 2.1 > -1.111
@assert 1.2 >= -2.0
@assert 1.3 >= -1.3
@assert -1 < 2.2
@assert -1 <= 2.1
@assert -1 <= -1.0
@assert 2 > -1.111
@assert 1 >= -2.0
@assert 1 >= -1.3
@assert -1.1 < 2
@assert -1.2 <= 2
@assert -1.0 <= 1
@assert 2.1 > -1
@assert 1.2 >= -2
@assert 1.3 >= -1
@assert -1 > -2
@assert -1 >= -2
@assert -1 >= -1
@assert -2 < -1
@assert -1 >= -2
@assert -1 >= -1
@assert -1.1 > -2.2
@assert -1.2 >= -2.1
@assert -1.0 >= -1.0
@assert -2.1 < -1.111
@assert -1.2 <= -1.1
@assert -1.3 <= -1.3
@assert -1 > -2.2
@assert -1 >= -2.1
@assert -1 >= -1.0
@assert -2 < -1.111
@assert -1 <= -.98765
@assert -1 >= -1.3
@assert -1.1 > -2
@assert -1.2 >= -2
@assert -1.0 >= -1
@assert -2.1 < -1
@assert -1.2 >= -2
@assert -1.3 <= -1
// Ordre sur les strings
@assert "" < "a"
@assert "a" < "ab"
@assert "a" < "ab"
@assert "ab" < "abc"
@assert "" <= ""
@assert "x" <= "x"
@assert "" <= "a"
@assert "a" <= "ab"
@assert "a" <= "ab"
@assert "ab" <= "abc"
@assert "a" > ""
@assert "ab" > "a"
@assert "ab" > "aa"
@assert "abc" > "aba"
@assert "" >= ""
@assert "a" >= "a"
@assert "b" >= "a"
@assert "ab" >= "aa"
@assert "ab" >= "aac"
@assert "abc" >= "abc"
@assert "" == ""
@assert "abc" == "abc"
@assert true == true
@assert false == false
@assert 0 == 0
@assert 1 == 1
@assert -1 == -1
@assert 0. == 0.0
@assert 1.0 == 1.
@assert -1. == -1.0
@assert 0 == 0.0
@assert 1 == 1.0
@assert -10 == -10.0
@assert 0 == -0
@assert 0.00 == -0.00
// String
@assert ("" + "def" == "def")
@assert ("abc" + "" == "abc")
@assert ("abc" + "def" == "abcdef")
@assert ("abcdef" == "abc" + "def")
// Operateur logique
@assert 1
@assert -1
@assert ! 0
@assert "ok"
@assert !""
@assert 0.1
@assert -123.4
@assert ! 0.0000
@assert true
@assert ! false
@assert true && true
@assert !(true && false)
@assert !(false && true)
@assert !(false && false)
@assert true || true
@assert true || false
@assert false || true
@assert !(false || false)
// Verif de la lazyness
@proc_def ::f()
{
@assert false
}
@assert true || ::f()
@assert !(false && ::f())
@assert (true ? true : false)