public void EnumMemberImplementedAsNumericConstantIsImported()
        {
            var md = new MockMetadataImporter {
                GetFieldSemantics = f => f.Name == "Member2" ? FieldScriptSemantics.NumericConstant(123, "$" + f.Name) : FieldScriptSemantics.Field("$" + f.Name)
            };

            Compile(new[] { "enum MyEnum { Member1, Member2, Member3 }" }, metadataImporter: md);
            FindEnum("MyEnum").Values.Select(v => v.Name).Should().BeEquivalentTo(new[] { "$Member1", "$Member2", "$Member3" });
        }
Beispiel #2
0
        public void ReadingFieldImplementedAsConstantWorks()
        {
            AssertCorrect(
                @"
public int F1;
public int F2;
public int F3;
public int F4;

public void M() {
	// BEGIN
	var f1 = F1;
	var f2 = F2;
	var f3 = F3;
	var f4 = F4;
	// END
}",
                @"	var $f1 = null;
	var $f2 = 'abcd';
	var $f3 = 1234.5;
	var $f4 = true;
", metadataImporter: new MockMetadataImporter {
                GetFieldSemantics = f => f.Name == "F1" ? FieldScriptSemantics.NullConstant() : (f.Name == "F2" ? FieldScriptSemantics.StringConstant("abcd") : (f.Name == "F3" ? FieldScriptSemantics.NumericConstant(1234.5) : (f.Name == "F4" ? FieldScriptSemantics.BooleanConstant(true) : FieldScriptSemantics.Field(f.Name))))
            });
        }