Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Victor Bandur
committed
Nov 18, 2016
1 parent
cd01a15
commit 3873795
Showing
3 changed files
with
55 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
core/vdm2c/src/test/resources/native/classes/ClassScratchWork_Tests.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "gtest/gtest.h" | ||
|
||
extern "C" | ||
{ | ||
#include "Vdm.h" | ||
#include <stdio.h> | ||
#include "ClassCollectionUpdate.h" | ||
} | ||
|
||
#define CHECK_TRUE(methodId) TVP c=_Z21ClassCollectionUpdateEV(NULL);\ | ||
TVP res=CALL_FUNC(ClassCollectionUpdate, ClassCollectionUpdate, c, methodId);\ | ||
EXPECT_EQ (true, res->value.boolVal);\ | ||
vdmFree(res);\ | ||
vdmFree(c) | ||
|
||
|
||
|
||
TEST(ClassScratchWork, op) | ||
{ | ||
CHECK_TRUE(CLASS_ClassCollectionUpdate__Z20updateSeqInstanceVarEV); | ||
} |
45 changes: 31 additions & 14 deletions
45
core/vdm2c/src/test/resources/vdmrt/classes/ClassScratchWork.vdmrt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,36 @@ | ||
class ScratchA | ||
end ScratchA | ||
class ClassCollectionUpdate | ||
|
||
instance variables | ||
|
||
ivarSeq : seq of nat := [1]; | ||
|
||
class ClassScratchWork | ||
operations | ||
op : () ==> () | ||
op() == | ||
|
||
public updateSeqInstanceVar : () ==> bool | ||
updateSeqInstanceVar () == | ||
( | ||
dcl a : ScratchA := new ScratchA(); | ||
dcl b : ScratchA; | ||
dcl c : int := 0; | ||
dcl d: int; | ||
b := a; | ||
d := c; | ||
c := 3; | ||
) | ||
end ClassScratchWork | ||
ivarSeq(1) := 5; | ||
return ivarSeq(1) = 5; | ||
); | ||
|
||
end ClassCollectionUpdate | ||
|
||
--class ScratchA | ||
--end ScratchA | ||
-- | ||
--class ClassScratchWork | ||
--operations | ||
--op : () ==> () | ||
--op() == | ||
--( | ||
-- dcl a : ScratchA := new ScratchA(); | ||
-- dcl b : ScratchA; | ||
-- dcl c : int := 0; | ||
-- dcl d: int; | ||
-- b := a; | ||
-- d := c; | ||
-- c := 3; | ||
-- ) | ||
--end ClassScratchWork | ||
-- This test illustrates that assignment needs to be more sophisticated to achieve value semantics. | ||
-- Check generated code to observe aliasing. |