local void testScobindConditionMulti(void) { Stab stabGlobal, stabFile, stab; AbSyn ab; initFile(); stabGlobal = stabNewGlobal(); stabFile = stabNewFile(stabGlobal); stab = stabPushLevel(stabFile, sposNone, STAB_LEVEL_LARGE); finiFile(); return; /* ideally, I'd like to test this here, but comsgNote (used for multiple defs) doesn't play nice. */ #if 0 AbSyn ab = abqParse("if A then { f: X == 1; f: X == 1}"); scopeBind(stab, ab); Symbol sym_f = symInternConst("f"); scobindTestCheckUnique(stab, sym_f); #endif }
local void testSymeAddCondition() { String B_imp = "import from Boolean"; String C_txt = "C: Category == with"; String D1_txt = "D1: with == add"; String D2_txt = "D2: with == add"; StringList lines = listList(String)(4, B_imp, C_txt, D1_txt, D2_txt); AbSynList code = listCons(AbSyn)(stdtypes(), abqParseLines(lines)); AbSyn absyn = abNewSequenceL(sposNone, code); initFile(); Stab stab = stabFile(); abPutUse(absyn, AB_Use_NoValue); scopeBind(stab, absyn); typeInfer(stab, absyn); AbSyn D1 = abFrSyme(uniqueMeaning(stabFile(), "D1")); AbSyn D2 = abFrSyme(uniqueMeaning(stabFile(), "D2")); AbSyn C = abFrSyme(uniqueMeaning(stabFile(), "C")); Syme syme1 = symeNewExport(symInternConst("syme2"), tfNewAbSyn(TF_General, id("D")), car(stab)); symeAddCondition(syme1, sefo(has(D1, C)), true); testIntEqual("test1", 1, listLength(Sefo)(symeCondition(syme1))); Syme syme2 = symeNewExport(symInternConst("syme1"),tfNewAbSyn(TF_General, id("D")), car(stab)); symeAddCondition(syme2, sefo(and(has(D1, C), has(D2, C))), true); testIntEqual("test2", 2, listLength(Sefo)(symeCondition(syme2))); finiFile(); }
local void testSymeSExpr() { String aSimpleDomain = "+++Comment\nDom: Category == with {f: () -> () ++ f\n}"; StringList lines = listList(String)(1, aSimpleDomain); AbSynList code = listCons(AbSyn)(stdtypes(), abqParseLines(lines)); AbSyn absyn = abNewSequenceL(sposNone, code); initFile(); Stab stab = stabFile(); abPutUse(absyn, AB_Use_NoValue); scopeBind(stab, absyn); typeInfer(stab, absyn); testTrue("Declare is sefo", abIsSefo(absyn)); testIntEqual("Error Count", 0, comsgErrorCount()); SymeList symes = stabGetMeanings(stab, ablogFalse(), symInternConst("Dom")); testIntEqual("unique meaning", 1, listLength(Syme)(symes)); Syme syme = car(symes); SExpr sx = symeSExprAList(syme); finiFile(); }
local void testScobind(void) { Stab stabGlobal, stabFile, stab; AbSyn ab; initFile(); stabGlobal = stabNewGlobal(); stabFile = stabNewFile(stabGlobal); stab = stabPushLevel(stabFile, sposNone, STAB_LEVEL_LARGE); ab = abqParse("X: with == add"); scopeBind(stab, ab); scobindTestCheckUnique(stab, symInternConst("X")); finiFile(); }
local void testScobindCondition(void) { Stab stabGlobal, stabFile, stab; AbSyn ab; Symbol sym_f; initFile(); stabGlobal = stabNewGlobal(); stabFile = stabNewFile(stabGlobal); stab = stabPushLevel(stabFile, sposNone, STAB_LEVEL_LARGE); ab = abqParse("if A then f: () -> ()"); scopeBind(stab, ab); sym_f = symInternConst("f"); scobindTestCheckUnique(stab, sym_f); finiFile(); }
local void testDocco() { StringList text; AbSyn code; initFile(); text = listList(String)(3, "+++ Words", "a: B;", " ++ more words"); code = abqParseLinesAsSeq(text); testAIntEqual("an id", AB_Declare, abTag(code)); testStringEqual("docs", " Words\n more words\n", docString(abComment(abDefineeId(code)))); text = listList(String)(2, "a: B;", " ++ some words"); code = abqParseLinesAsSeq(text); testAIntEqual("an id", AB_Declare, abTag(code)); testStringEqual("docs", " some words\n", docString(abComment(abDefineeId(code)))); text = listList(String)(2, "+++ ZZZ", "a: B;"); code = abqParseLinesAsSeq(text); testAIntEqual("an id", AB_Declare, abTag(code)); testStringEqual("docs", " ZZZ\n", docString(abComment(abDefineeId(code)))); finiFile(); }