Skip to content

Commit

Permalink
property assignment now requires an exact type match
Browse files Browse the repository at this point in the history
  • Loading branch information
bhaller committed Dec 22, 2023
1 parent fa1ade2 commit 6cfa23c
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 50 deletions.
1 change: 1 addition & 0 deletions VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Note that not every commit will be logged here; that is what the Github commit h
development head (in the master branch):
fix for #418, a crash involving null genomes in nonWF (has_null_genomes_ was not set correctly by addCloned() or takeMigrants() when putting a null genome into a subpop that previously had none)
policy change: float indices are no longer legal for subsetting, indices must be integer (or a logical vector, as usual); this was inherited from R and is a bad idea for Eidos
policy change: assignment into object properties must match the type of the property; no more promotion to integer/float from lower types


version 4.1 (Eidos version 3.1):
Expand Down
28 changes: 17 additions & 11 deletions core/slim_test_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1923,22 +1923,28 @@ void _RunIndividualTests(void)
SLiMAssertScriptStop(gen1_setup_i1xyz + "1 early() { i = p1.individuals; i.setSpatialPosition(1.0:30); if (identical(i.z, (1.0:10)*3)) stop(); }", __LINE__);

// Some specific testing for setting of accelerated properties
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tag = (seqAlong(i) % 2 == 0); if (all(i.tag == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__);
SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tag = (seqAlong(i) % 2 == 0); }", "cannot be type logical", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tag = asInteger(seqAlong(i) % 2 == 0); if (all(i.tag == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tag = seqAlong(i); if (all(i.tag == seqAlong(i))) stop(); }", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tagF = (seqAlong(i) % 2 == 0); if (all(i.tagF == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tagF = seqAlong(i); if (all(i.tagF == seqAlong(i))) stop(); }", __LINE__);
SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tagF = (seqAlong(i) % 2 == 0); }", "cannot be type logical", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tagF = asFloat(seqAlong(i) % 2 == 0); if (all(i.tagF == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__);
SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tagF = seqAlong(i); }", "cannot be type integer", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tagF = asFloat(seqAlong(i)); if (all(i.tagF == seqAlong(i))) stop(); }", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.fitnessScaling = (seqAlong(i) % 2 == 0); if (all(i.fitnessScaling == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.fitnessScaling = seqAlong(i); if (all(i.fitnessScaling == seqAlong(i))) stop(); }", __LINE__);
SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.fitnessScaling = (seqAlong(i) % 2 == 0); }", "cannot be type logical", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.fitnessScaling = asFloat(seqAlong(i) % 2 == 0); if (all(i.fitnessScaling == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__);
SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.fitnessScaling = seqAlong(i); }", "cannot be type integer", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.fitnessScaling = asFloat(seqAlong(i)); if (all(i.fitnessScaling == seqAlong(i))) stop(); }", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.x = (seqAlong(i) % 2 == 0); if (all(i.x == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.x = seqAlong(i); if (all(i.x == seqAlong(i))) stop(); }", __LINE__);
SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.x = (seqAlong(i) % 2 == 0); }", "cannot be type logical", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.x = asFloat(seqAlong(i) % 2 == 0); if (all(i.x == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__);
SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.x = seqAlong(i); if (all(i.x == seqAlong(i))) stop(); }", "cannot be type integer", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.x = asFloat(seqAlong(i)); if (all(i.x == seqAlong(i))) stop(); }", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.y = (seqAlong(i) % 2 == 0); if (all(i.y == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.y = seqAlong(i); if (all(i.y == seqAlong(i))) stop(); }", __LINE__);
SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.y = (seqAlong(i) % 2 == 0); }", "cannot be type logical", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.y = asFloat(seqAlong(i) % 2 == 0); if (all(i.y == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__);
SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.y = seqAlong(i); if (all(i.y == seqAlong(i))) stop(); }", "cannot be type integer", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.y = asFloat(seqAlong(i)); if (all(i.y == seqAlong(i))) stop(); }", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.z = (seqAlong(i) % 2 == 0); if (all(i.z == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.z = seqAlong(i); if (all(i.z == seqAlong(i))) stop(); }", __LINE__);
SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.z = (seqAlong(i) % 2 == 0); }", "cannot be type logical", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.z = asFloat(seqAlong(i) % 2 == 0); if (all(i.z == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__);
SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.z = seqAlong(i); if (all(i.z == seqAlong(i))) stop(); }", "cannot be type integer", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.z = asFloat(seqAlong(i)); if (all(i.z == seqAlong(i))) stop(); }", __LINE__);
SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.color = format('#%.6X', seqAlong(i)); if (all(i.color == format('#%.6X', seqAlong(i)))) stop(); }", __LINE__);

Expand Down
Loading

0 comments on commit 6cfa23c

Please sign in to comment.