def test_assignment_name_boolean(self):
        script = 'Name = true'
        expected = [Assignment(Identifier(Name('Name')), Value(True))]
        actually = self.parser.parse(script)
        self.assertEqual(expected, actually)

        script = 'Name = false'
        expected = [Assignment(Identifier(Name('Name')), Value(False))]
        actually = self.parser.parse(script)
        self.assertEqual(expected, actually)
    def test_assignment_uri_boolean(self):
        script = '<http://uri.org/> = true'
        expected = [
            Assignment(Identifier(Uri('http://uri.org/')), Value(True))
        ]
        actually = self.parser.parse(script)
        self.assertEqual(expected, actually)

        script = '<http://uri.org/> = false'
        expected = [
            Assignment(Identifier(Uri('http://uri.org/')), Value(False))
        ]
        actually = self.parser.parse(script)
        self.assertEqual(expected, actually)
Example #3
0
    def test_assignment_uri_uri(self):
        name = Identifier(Uri('http://variable/#v'))
        value = Identifier(Uri('http://variable/#value'))

        self.assertEqual(Assignment(name, value).evaluate(
            self.env), value.evaluate(self.env))
        self.assertEqual(name.evaluate(self.env), value.evaluate(self.env))
Example #4
0
    def test_assignment_name_name(self):
        name = Identifier(Name('variable'))
        value = Identifier(Name('value'))

        self.assertEqual(Assignment(name, value).evaluate(
            self.env), value.evaluate(self.env))
        self.assertEqual(name.evaluate(self.env), value.evaluate(self.env))
Example #5
0
    def test_assignment_self_name(self):
        name = Identifier(Self(), Name('v'))
        value = Identifier(Name('Name'))

        self.assertEqual(Assignment(name, value).evaluate(
            self.env), value.evaluate(self.env))
        self.assertEqual(name.evaluate(self.env), value.evaluate(self.env))
 def test_assignment_uri_double(self):
     script = '<http://uri.org/> = 0.12345'
     expected = [
         Assignment(Identifier(Uri('http://uri.org/')), Value(0.12345))
     ]
     actually = self.parser.parse(script)
     self.assertEqual(expected, actually)
 def test_assignment_uri_string(self):
     script = '<http://uri.org/> = "hello"'
     expected = [
         Assignment(Identifier(Uri('http://uri.org/')), Value("hello"))
     ]
     actually = self.parser.parse(script)
     self.assertEqual(expected, actually)
 def test_assignment_name_name(self):
     script = 'Name = Name'
     expected = [
         Assignment(Identifier(Name('Name')), Identifier(Name('Name')))
     ]
     actually = self.parser.parse(script)
     self.assertEqual(expected, actually)
 def test_assignment_name_uri(self):
     script = 'Name = <http://uri.org/>'
     expected = [
         Assignment(Identifier(Name('Name')),
                    Identifier(Uri('http://uri.org/')))
     ]
     actually = self.parser.parse(script)
     self.assertEqual(expected, actually)
 def test_assignment_uri_uri(self):
     script = '<http://uri.org/> = <http://value.org>'
     expected = [
         Assignment(Identifier(Uri('http://uri.org/')),
                    Identifier(Uri('http://value.org')))
     ]
     actually = self.parser.parse(script)
     self.assertEqual(expected, actually)
 def test_assignment_uri_expansion(self):
     script = '<expansion> = e is a t()'
     expected = [
         Assignment(
             Identifier(Uri('expansion')),
             Expansion(Identifier(Name('e')), Identifier(Name('t')), [],
                       []))
     ]
     actually = self.parser.parse(script)
     self.assertEqual(expected, actually)
Example #12
0
    def run(self, triplepack, env):
        self.import_pragma.evaluate(env)
        user_prefix = env.uri_for_prefix(env.prefix)
        
        for k in env._template_table.keys():
            if env.uri_for_prefix(self.namespace).uri in k.uri:
                name = Identifier(user_prefix,Uri(k.split()[-1]))
                assignment = Assignment(name,k)
                assignment.evaluate(env)
        
        to_evaulate = []
        for k,v in env._symbol_table.items():
            #if env.uri_for_prefix(self.namespace).uri in v.uri:
            name = Identifier(user_prefix,Uri(k.split()[-1]))
            assignment = Assignment(name,v)
            to_evaulate.append(Assignment(name,v))
        for assignment in to_evaulate:
            assignment.evaluate(env)

        # Triplepack is unchanged but its needed for the late binding that occurs with extensions.
        return triplepack
 def test_assignment_name_double(self):
     script = 'Name = 0.12345'
     actually = self.parser.parse(script)
     expected = [Assignment(Identifier(Name('Name')), Value(0.12345))]
     self.assertEqual(expected, actually)
 def test_assignment_name_integer(self):
     script = 'Name = 12345'
     expected = [Assignment(Identifier(Name('Name')), Value(12345))]
     actually = self.parser.parse(script)
     self.assertEqual(expected, actually)
 def test_assignment_name_string(self):
     script = 'Name = "hello"'
     expected = [Assignment(Identifier(Name('Name')), Value("hello"))]
     actually = self.parser.parse(script)
     self.assertCountEqual(expected, actually)