Added macro for getproperty (setter is private). Preserve documentation

#region license
// Copyright (c) 2010 Rodrigo B. de Oliveira (rbo@acm.org)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//     * Neither the name of Rodrigo B. de Oliveira nor the names of its
//     contributors may be used to endorse or promote products derived from this
//     software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion

namespace Boo.Lang.Extensions

import System
import Boo.Lang.Compiler.Ast

macro property:

	raise "property <name> [as type] [= initialValue]" unless PropertyMacroParser.IsValidProperty(property)

	argument = property.Arguments[0]
	initializationForm = argument as BinaryExpression
	if initializationForm is not null:
		declaration = initializationForm.Left
		initializer = initializationForm.Right
	else:
		declaration = argument
		initializer = null

	name = PropertyMacroParser.PropertyNameFrom(declaration)
	type = PropertyMacroParser.PropertyTypeFrom(declaration)
	backingField = ReferenceExpression(Name: Context.GetUniqueName(name.ToString()))

	prototype = [|

		class _:

			private $backingField as $type = $initializer

			$name:
				get: return $backingField
				set: $backingField = value
	|]
	prototype.Members[name.ToString()].Documentation = property.Documentation

	yieldAll prototype.Members

macro getproperty:

	raise "getproperty <name> [as type] [= initialValue]" unless PropertyMacroParser.IsValidProperty(getproperty)

	argument = getproperty.Arguments[0]
	initializationForm = argument as BinaryExpression
	if initializationForm is not null:
		declaration = initializationForm.Left
		initializer = initializationForm.Right
	else:
		declaration = argument
		initializer = null

	name = PropertyMacroParser.PropertyNameFrom(declaration)
	type = PropertyMacroParser.PropertyTypeFrom(declaration)
	backingField = ReferenceExpression(Name: Context.GetUniqueName(name.ToString()))

	prototype = [|

		class _:

			private $backingField as $type = $initializer

			$name:
				get: return $backingField
				private set: $backingField = value
	|]
	prototype.Members[name.ToString()].Documentation = getproperty.Documentation

	yieldAll prototype.Members

internal static class PropertyMacroParser:

	def PropertyNameFrom(e as Expression) as ReferenceExpression:
		declaration = e as TryCastExpression
		if declaration is not null:
			return declaration.Target
		return e

	def PropertyTypeFrom(e as Expression):
		declaration = e as TryCastExpression
		if declaration is not null:
			return declaration.Type
		return null

	def IsValidProperty(property as MacroStatement):
		if len(property.Arguments) != 1:
			return false
		if not property.Body.IsEmpty:
			return false
		argument = property.Arguments[0]
		initializationForm = argument as BinaryExpression
		if initializationForm is not null:
			if initializationForm.Operator != BinaryOperatorType.Assign:
				return false
			return IsValidPropertyDeclaration(initializationForm.Left)
		return IsValidPropertyDeclaration(argument)

	def IsValidPropertyDeclaration(e as Expression):
		if e.NodeType == NodeType.ReferenceExpression:
			return true
		declaration = e as TryCastExpression
		if declaration is null: return false
		return declaration.Target.NodeType == NodeType.ReferenceExpression

#region license
// Copyright (c) 2010 Rodrigo B. de Oliveira (rbo@acm.org)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//     * Neither the name of Rodrigo B. de Oliveira nor the names of its
//     contributors may be used to endorse or promote products derived from this
//     software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion

namespace Boo.Lang.Extensions

import System
import Boo.Lang.Compiler.Ast

macro property:

	raise "property <name> [as type] [= initialValue]" unless PropertyMacroParser.IsValidProperty(property)

	argument = property.Arguments[0]
	initializationForm = argument as BinaryExpression
	if initializationForm is not null:
		declaration = initializationForm.Left
		initializer = initializationForm.Right
	else:
		declaration = argument
		initializer = null

	name = PropertyMacroParser.PropertyNameFrom(declaration)
	type = PropertyMacroParser.PropertyTypeFrom(declaration)
	backingField = ReferenceExpression(Name: Context.GetUniqueName(name.ToString()))

	prototype = [|

		class _:

			private $backingField as $type = $initializer

			$name:
				get: return $backingField
				set: $backingField = value
	|]

	yieldAll prototype.Members

internal static class PropertyMacroParser:

	def PropertyNameFrom(e as Expression) as ReferenceExpression:
		declaration = e as TryCastExpression
		if declaration is not null:
			return declaration.Target
		return e

	def PropertyTypeFrom(e as Expression):
		declaration = e as TryCastExpression
		if declaration is not null:
			return declaration.Type
		return null

	def IsValidProperty(property as MacroStatement):
		if len(property.Arguments) != 1:
			return false
		if not property.Body.IsEmpty:
			return false
		argument = property.Arguments[0]
		initializationForm = argument as BinaryExpression
		if initializationForm is not null:
			if initializationForm.Operator != BinaryOperatorType.Assign:
				return false
			return IsValidPropertyDeclaration(initializationForm.Left)
		return IsValidPropertyDeclaration(argument)

	def IsValidPropertyDeclaration(e as Expression):
		if e.NodeType == NodeType.ReferenceExpression:
			return true
		declaration = e as TryCastExpression
		if declaration is null: return false
		return declaration.Target.NodeType == NodeType.ReferenceExpression


html changelog generator, useful for publishing/archiving/linking online full changelog between versions [not only wrt jira].

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@3113 2c1201b4-01cd-e047-a400-b836ae1fbc61

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/BillHally/boo.git/'


useful in the past, might be useful in the future

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1030 2c1201b4-01cd-e047-a400-b836ae1fbc61


whichserver example

whichserver example

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@730 2c1201b4-01cd-e047-a400-b836ae1fbc61

import System.Net

using response=WebRequest.Create(argv[0]).GetResponse():
	print(response.Headers["Server"])

error: pathspec 'examples/whichserver.boo' did not match any file(s) known to git


fixed test case

fixed test case


added the regression for BOO-603 just in case

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2556 2c1201b4-01cd-e047-a400-b836ae1fbc61


visitor implementations benchmark

visitor implementations benchmark


property benchmarks should be using properties


test case for double precision literals

test case for double precision literals


procura os icones no path do exe

procura os icones no path do exe

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@439 2c1201b4-01cd-e047-a400-b836ae1fbc61


macro is more hip

macro is more hip

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1359 2c1201b4-01cd-e047-a400-b836ae1fbc61


coroutine simulation with generators

coroutine simulation with generators

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1499 2c1201b4-01cd-e047-a400-b836ae1fbc61


gtkshell, set only the font (not the size)

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1123 2c1201b4-01cd-e047-a400-b836ae1fbc61


custom scheduler example : lottery scheduler

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2825 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""RANDOM SCHEDULING
   the coroutines will be executed in any order, but they will still run their
   sliceshare at each round. Output could be :
id:2 / count:1
id:5 / count:1
id:6 / count:1
id:0 / count:1
id:0 / count:2
...
id:2 / count:10
bye!
"""

import System
import System.Collections.Generic
import Coroutine

class CountToTen(ISpawnable):
	[property(Id)]
	_id as int

	#look ma! no yield!
	#if you want control over the placement of yields, just apply [coroutine] as usual
	def Execute() as bool:
		for i in range(1, 11):
			print "id:${_id} / count:${i}"

class LotteryCoroutineScheduler(ICoroutineScheduler,IComparer of ISpawnable):

	_lock_IsRunning = object()

	IsRunning as bool:
		get:
			lock _lock_IsRunning:
				return _isRunning
	_isRunning = false

	_rand as Random

	def Compare(a as ISpawnable, b as ISpawnable) as int:
		return _rand.Next(-10, 10)

	def JoinStart():
		lock _lock_IsRunning:
			if _isRunning:
				raise InvalidOperationException("Scheduler is already running.")
			_isRunning = true
		_rand = Random()
		coroutines = CoroutineSchedulerManager.Coroutines #FIXME: sync copy
		slices = CoroutineSchedulerManager.Slices
		try:
			:runSlices
			toRemove as List[of ISpawnable] = null
			while 0 != coroutines.Count:
				coroutines.Sort(self)
				for c in coroutines:
					s = slices[c]
					try:
						if 1 == s:
							c.Execute()
						else:
							for i in range(0, s):
								c.Execute()
					except e as CoroutineTerminatedException:
						if toRemove is null:
							toRemove = List[of ISpawnable]()
						toRemove.Add(c)
					except e as CoroutineFutureNotReadyException:
						pass
				if toRemove is not null:
					for c in toRemove:
						coroutines.Remove(c)
					goto runSlices
		ensure:
			lock _lock_IsRunning:
				_isRunning = false

spawn CountToTen(Id:0), 2
for i in range(1, 11):
	spawn CountToTen(Id:i)

CoroutineSchedulerManager.Scheduler = LotteryCoroutineScheduler()
spawn

print "bye!"

error: pathspec 'examples/attributes/coroutine/spawn-1.boo' did not match any file(s) known to git


one more test case for enum casts

one more test case for enum casts

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1477 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
4
Bar
"""
import BooCompiler.Tests

print cast(int, ByteEnum.Baz)
print cast(ByteEnum, 2)

error: pathspec 'tests/testcases/integration/enums-14.boo' did not match any file(s) known to git


cast to enum is failing

cast to enum is failing

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1474 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
0
1
Item1
Item2
"""
enum E:
	Item1
	Item2

print cast(int, E.Item1)
print cast(int, E.Item2)
print cast(E, 0)
print cast(E, 1)

error: pathspec 'tests/testcases/integration/enums-13.boo' did not match any file(s) known to git


BOO-231 patch by Bill Wood

BOO-231 patch by Bill Wood

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1353 2c1201b4-01cd-e047-a400-b836ae1fbc61

a as object = 0.0
b as object = 1.0

assert true == (not a)
assert false == (not b)
assert false == ((not b) == (not a))
assert true == (not a)

error: pathspec 'tests/testcases/regression/BOO-231-1.boo' did not match any file(s) known to git


replace double negative with simpler test

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2694 2c1201b4-01cd-e047-a400-b836ae1fbc61


BOO-723

BOO-723

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2222 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
6
"""
class Program:
	def run():
		y = rwar2()
		print y[3]

class rwar1:
	self[i as int]:
		get:
			return i*2
		set:
			pass

class rwar2(rwar1):
	pass

Program().run()

error: pathspec 'tests/testcases/regression/BOO-723-1.boo' did not match any file(s) known to git


fix test exception handler

fix test exception handler


one more test case for enum casts


test case to proove BOO-121 is fixed

test case to proove BOO-121 is fixed

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2010 2c1201b4-01cd-e047-a400-b836ae1fbc61

class Attributes:

	_attributes = []

	Item(index as int):
		get:
			return _attributes[index]

	Item(name as string):
		get:
			return [attr for attr as Attribute
					in _attributes
					if name == attr.Name]

	def Add([required] attr as Attribute):
		_attributes.Add(attr)

class Attribute:
	[property(Name)]
	_name = ""

a1 = Attribute(Name: "foo")
a2 = Attribute(Name: "foo")
a3 = Attribute(Name: "bar")

attributes = Attributes()
attributes.Add(a1)
attributes.Add(a2)
attributes.Add(a3)

assert attributes.Item["foo"] == [a1, a2]
assert attributes.Item["bar"] == [a3]
assert attributes.Item[0] == a1
assert attributes.Item[-1] == a3

error: pathspec 'tests/testcases/regression/BOO-121-1.boo' did not match any file(s) known to git


ResourceFu

ResourceFu

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@1861 2c1201b4-01cd-e047-a400-b836ae1fbc61


simple property macro for more convenient declaration of class read/write properties


GtkSourceView based interactive shell

GtkSourceView based interactive shell

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1462 2c1201b4-01cd-e047-a400-b836ae1fbc61


cannot reproduce static property bug; added testcase

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1217 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
1.0
1.1
"""
class Information:

	[property(Version)]
	static _version = "1.0"

print Information.Version
Information.Version = "1.1"
print Information.Version

error: pathspec 'tests/testcases/integration/properties-25.boo' did not match any file(s) known to git


Added

Added

import Boo.Lang.Compiler
import Boo.Lang.Compiler.Ast
import Boo.Lang.Compiler.Ast.Visitors

class AliasMacro(AbstractAstMacro):

	static final Usage = "Usage: alias <expression> as <name>"

	override def Expand(macro as MacroStatement):
		if not CheckUsage(macro):
			Errors.Add(
				CompilerErrorFactory.CustomError(macro.LexicalInfo, Usage))
			return null

		argument as TryCastExpression = macro.Arguments[0]
		reference = ReferenceExpression(Name: argument.Type.ToString())
		macro.ParentNode.ReplaceNodes(reference, argument.Target)

	def CheckUsage(macro as MacroStatement):
		if len(macro.Block.Statements) > 0: return false
		if len(macro.Arguments) != 1: return false
		expression = macro.Arguments[0] as TryCastExpression
		if expression is null: return false
		return expression.Type isa SimpleTypeReference

error: pathspec 'src/BooBuddy/AliasMacro.boo' did not match any file(s) known to git


CompileToFile

CompileToFile

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@1931 2c1201b4-01cd-e047-a400-b836ae1fbc61


help also describes events now

help also describes events now

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1235 2c1201b4-01cd-e047-a400-b836ae1fbc61


forgot this one in previous commit.

forgot this one in previous commit.

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2419 2c1201b4-01cd-e047-a400-b836ae1fbc61


one more test case

one more test case

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2725 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
public bar as string = ''
"""
fieldName = "bar"
fieldType = "string"
fieldInitializer = ""
field = [|
	public $fieldName as $fieldType = $fieldInitializer
|]
print field.ToCodeString()

error: pathspec 'tests/testcases/integration/meta-programming/field-splicing-1.boo' did not match any file(s) known to git


forgot to check the test case in

forgot to check the test case in

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2740 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
(a as Foo[of T])
(a as Foo[of T])
"""
import Boo.Lang.Compiler.Ast

def test(e as TypeDefinition):
	code = [| a as $e |]
	print code.ToCodeString()

	oldTypeRef = code.Type
	code = [| a as $(code.Type) |]
	assert code.Type is not oldTypeRef // must be cloned ref
	print code.ToCodeString()

typeDef = [|
	class Foo of T:
		pass
|]
test(typeDef)

error: pathspec 'tests/testcases/integration/meta-programming/typeref-splicing-3.boo' did not match any file(s) known to git


field order test case

field order test case

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1693 2c1201b4-01cd-e047-a400-b836ae1fbc61


add testcase for pointer to instance or static field

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@3310 2c1201b4-01cd-e047-a400-b836ae1fbc61


Adding a meta method to simplify Default expressions

namespace Boo.Lang.Extensions

import System
import Boo.Lang.Compiler.Ast

[Meta]
def Default(t as Expression) as Expression:
	return [|__default__($t)|]

error: pathspec 'src/Boo.Lang.Extensions/Macros/DefaultMetaMethod.boo' did not match any file(s) known to git


adding boo hello world

adding boo hello world

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/dumptyd/hello-world.git/'


multimethods example for GB

multimethods example for GB

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2034 2c1201b4-01cd-e047-a400-b836ae1fbc61


BOO-549 test case

BOO-549 test case

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@1979 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
1
"""
class X:
	def T(params as int) as System.Collections.IEnumerable:
		return Y.T()

class Y:
	public static T = def():
		yield 1

g = X().T(1).GetEnumerator()
item, = g
print item
assert not g.MoveNext()

error: pathspec 'tests/testcases/regression/BOO-549-1.boo' did not match any file(s) known to git


stacktrace/traceback example

stacktrace/traceback example

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@1967 2c1201b4-01cd-e047-a400-b836ae1fbc61

import System

def foo():
	print Environment.StackTrace

def bar():
	foo()

bar()

error: pathspec 'examples/stacktrace.boo' did not match any file(s) known to git


Mono.GetOptions example

Mono.GetOptions example

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@947 2c1201b4-01cd-e047-a400-b836ae1fbc61


BOO-723

BOO-723

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2222 2c1201b4-01cd-e047-a400-b836ae1fbc61


splice works for statements and blocks too now; Added Statement.ToBlock to make it easy to get a block; TraceMethodCallsAttribute is now making more use the meta-programming support

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2590 2c1201b4-01cd-e047-a400-b836ae1fbc61


BOO-835: DSL-friendly method syntax, Let's give it a testcase.

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2923 2c1201b4-01cd-e047-a400-b836ae1fbc61


multiline member references test case

multiline member references test case

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2370 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
page = Builder()
page.Foo()
page = Builder()
page.Html.Head.Body.Output()
print 'foo'
"""
page = Builder()
page.Foo()

page = Builder()
page.
    Html.
        Head
		.Body.
    Output()

print "foo"

error: pathspec 'tests/testcases/parser/wsa/member-references-1.boo' did not match any file(s) known to git


GtkSourceView based interactive shell

GtkSourceView based interactive shell

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1462 2c1201b4-01cd-e047-a400-b836ae1fbc61

#region license
// Copyright (c) 2004, Rodrigo B. de Oliveira (rbo@acm.org)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//     * Neither the name of Rodrigo B. de Oliveira nor the names of its
//     contributors may be used to endorse or promote products derived from this
//     software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion

import System
import Gtk from "gtk-sharp"
import GtkSourceView from "gtksourceview-sharp"
import Gdk from "gdk-sharp" as Gdk
import Pango from "pango-sharp" as Pango
import Boo.Lang.Interpreter from Boo.Lang.Interpreter

class PromptView(SourceView):

	_interpreter = InteractiveInterpreter(RememberLastValue: true, Print: print)

	def constructor():
		super(
			SourceBuffer(
				SourceLanguagesManager().GetLanguageFromMimeType("text/x-boo"),
				Highlight: true))
		self.WrapMode = Gtk.WrapMode.Word

		//if Environment.OSVersion.Platform in PlatformID.Win32NT, PlatformID.Win32Windows:
		self.ModifyFont(Pango.FontDescription(Family: "Lucida Console"))

		_interpreter.References.Add(typeof(TextView).Assembly)
		_interpreter.References.Add(typeof(Gdk.Key).Assembly)

		_interpreter.SetValue("cls", { Buffer.Text = "" })
		_interpreter.SetValue("view", self)

		prompt()

	override def OnKeyPressEvent(ev as Gdk.EventKey):
		if Gdk.Key.Return == ev.Key:
			try:
				EvalCurrentLine()
			except x:
				print(x)
			prompt()
			return true
		elif ev.Key in Gdk.Key.BackSpace, Gdk.Key.Left:
			if Buffer.GetIterAtMark(Buffer.InsertMark).LineOffset < 5:
				return true

		return super(ev)

	def print(obj):
		Buffer.InsertAtCursor("${obj}\n")

	def prompt():
		Buffer.MoveMark(Buffer.InsertMark, Buffer.EndIter)
		Buffer.InsertAtCursor(">>> ")
		ScrollMarkOnscreen(Buffer.InsertMark)

	def EvalCurrentLine():
		start = Buffer.GetIterAtLine(Buffer.LineCount)
		line = Buffer.GetText(start, Buffer.EndIter, false)

		print("")
		_interpreter.LoopEval(line[4:])

class MainWindow(Window):

	def constructor():
		super("booish")

		window = ScrolledWindow()
		window.Add(PromptView())

		self.Add(window)

		self.DeleteEvent += Application.Quit

Application.Init()

window = MainWindow(DefaultWidth:  400,
				DefaultHeight: 250)

window.ShowAll()

Application.Run()

error: pathspec 'examples/gtk/gsvshell.boo' did not match any file(s) known to git


do not repeat run-time exceptions.

do not repeat run-time exceptions.

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2988 2c1201b4-01cd-e047-a400-b836ae1fbc61

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/BillHally/boo.git/'


BOO-52 Boo Explorer Output Window - patch sent by Mike Douglas

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@773 2c1201b4-01cd-e047-a400-b836ae1fbc61


tcp echo server example

tcp echo server example

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@322 2c1201b4-01cd-e047-a400-b836ae1fbc61

import System.IO
import System.Net
import System.Net.Sockets

server = Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
server.Bind(IPEndPoint(IPAddress.Any, 8080))
server.Listen(1)

while true:
	socket = server.Accept()
	using stream=NetworkStream(socket, true):
		using reader=StreamReader(stream):
			print(reader.ReadLine())

error: pathspec 'examples/server.boo' did not match any file(s) known to git


Build script now includes WP7 dll in package.

project_name = "FluentValidation"
solution_file = "FluentValidation.sln"
solution_file_silverlight = "FluentValidation.Silverlight.sln"
project_configuration = "release"
build_dir = "build"
test_assemblies = ("src/FluentValidation.Tests/bin/${project_configuration}/FluentValidation.Tests.dll",
  "src/FluentValidation.Tests.Mvc1/bin/${project_configuration}/FluentValidation.Tests.Mvc1.dll")
build_silverlight = false
ncover_path = "C:/Program Files (x86)/ncover"

target default, (init, compile, compile_silverlight, test, deploy, package):
  pass

target ci, (init, silverlight, compile, compile_silverlight, coverage, package):
  pass

target init:
  rm(build_dir)
  rm("teamcity-info.xml")

desc "Enables silverlight build"
target silverlight:
  print "Silverlight build enabled"
  build_silverlight = true

desc "Compiles solution"
target compile:
  msbuild(file: solution_file, configuration: project_configuration, version: "4", properties: { "TrackFileAccess" : false } )

desc "Compiles silverlight"
target compile_silverlight:
  if build_silverlight:
    msbuild(file: solution_file_silverlight, configuration: project_configuration, version: "4")

desc "Runs tests"
target test:
  nunit(assemblies: test_assemblies)

desc "Creates release package"
target deploy:
  #main binaries
  with FileList("src/FluentValidation/bin/${project_configuration}"):
    .Include("**/*")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}/FluentValidation")

  #Mvc2 integration
  with FileList("src/FluentValidation.Mvc/bin/${project_configuration}"):
    .Include("FluentValidation.Mvc.*")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}/MVC/MVC2")

  #mvc1 integration
  with FileList("src/FluentValidation.Mvc1/bin/${project_configuration}"):
    .Include("FluentValidation.Mvc.*")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}/MVC/MVC1")

  #xVal
  with FileList("src/FluentValidation.xValIntegration/bin/${project_configuration}"):
    .Include("FluentValidation.xValIntegration.*")
    .Include("xVal.dll")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}/Experimental/xVal")

  #silverlight & WP7
  if build_silverlight:
    with FileList("src/FluentValidation.Silverlight/bin/${project_configuration}"):
      .Include("**/*")
      .ForEach def(file):
        file.CopyToDirectory("${build_dir}/${project_configuration}/Silverlight")

    with FileList("src/FluentValidation.WP7/bin/${project_configuration}"):
      .Include("**/*")
      .ForEach def(file):
        file.CopyToDirectory("${build_dir}/${project_configuration}/WP7")

  #License/Changelog
  with FileList():
    .Include("License.txt")
    .Include("Changelog.txt")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}")

target package, (deploy):
  zip("${build_dir}/${project_configuration}", "${build_dir}/FluentValidation.zip")

target coverage:
  ncover_path = "c:/program files (x86)/ncover"
  app_assemblies = ("FluentValidation", "FluentValidation.Mvc", "FluentValidation.xValIntegration")
  teamcity_launcher = env("teamcity.dotnet.nunitlauncher")

  with ncover():
    .toolPath = "${ncover_path}/NCover.console.exe"
    .reportDirectory = "${build_dir}/Coverage"
    .workingDirectory = "src/FluentValidation.Tests/bin/${project_configuration}"
    .applicationAssemblies = app_assemblies
    .program = "${teamcity_launcher} v2.0 x86 NUnit-2.4.6"
    .testAssembly = "FluentValidation.Tests.dll"
    .excludeAttributes = "System.Runtime.CompilerServices.CompilerGeneratedAttribute"

  with ncover_explorer():
    .toolPath = "${ncover_path}/NCoverExplorer.console.exe"
    .project = "FluentValidation"
    .reportDirectory = "build/coverage"

project_name = "FluentValidation"
solution_file = "FluentValidation.sln"
solution_file_silverlight = "FluentValidation.Silverlight.sln"
project_configuration = "release"
build_dir = "build"
test_assemblies = ("src/FluentValidation.Tests/bin/${project_configuration}/FluentValidation.Tests.dll",
  "src/FluentValidation.Tests.Mvc1/bin/${project_configuration}/FluentValidation.Tests.Mvc1.dll")
build_silverlight = false
ncover_path = "C:/Program Files (x86)/ncover"

target default, (init, compile, compile_silverlight, test, deploy, package):
  pass

target ci, (init, silverlight, compile, compile_silverlight, coverage, package):
  pass

target init:
  rm(build_dir)
  rm("teamcity-info.xml")

desc "Enables silverlight build"
target silverlight:
  print "Silverlight build enabled"
  build_silverlight = true

desc "Compiles solution"
target compile:
  msbuild(file: solution_file, configuration: project_configuration, version: "4", properties: { "TrackFileAccess" : false } )

desc "Compiles silverlight"
target compile_silverlight:
  if build_silverlight:
    msbuild(file: solution_file_silverlight, configuration: project_configuration, version: "4")

desc "Runs tests"
target test:
  nunit(assemblies: test_assemblies)

desc "Creates release package"
target deploy:
  #main binaries
  with FileList("src/FluentValidation/bin/${project_configuration}"):
    .Include("**/*")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}/FluentValidation")

  #Mvc2 integration
  with FileList("src/FluentValidation.Mvc/bin/${project_configuration}"):
    .Include("FluentValidation.Mvc.*")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}/MVC/MVC2")

  #mvc1 integration
  with FileList("src/FluentValidation.Mvc1/bin/${project_configuration}"):
    .Include("FluentValidation.Mvc.*")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}/MVC/MVC1")

  #xVal
  with FileList("src/FluentValidation.xValIntegration/bin/${project_configuration}"):
    .Include("FluentValidation.xValIntegration.*")
    .Include("xVal.dll")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}/Experimental/xVal")

  #silverlight
  if build_silverlight:
    with FileList("src/FluentValidation.Silverlight/bin/${project_configuration}"):
      .Include("*.{dll,pdb,xml}")
      .ForEach def(file):
        file.CopyToDirectory("${build_dir}/${project_configuration}/Experimental/Silverlight")

  #License/Changelog
  with FileList():
    .Include("License.txt")
    .Include("Changelog.txt")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}")

target package, (deploy):
  zip("${build_dir}/${project_configuration}", "${build_dir}/FluentValidation.zip")

target coverage:
  ncover_path = "c:/program files (x86)/ncover"
  app_assemblies = ("FluentValidation", "FluentValidation.Mvc", "FluentValidation.xValIntegration")
  teamcity_launcher = env("teamcity.dotnet.nunitlauncher")

  with ncover():
    .toolPath = "${ncover_path}/NCover.console.exe"
    .reportDirectory = "${build_dir}/Coverage"
    .workingDirectory = "src/FluentValidation.Tests/bin/${project_configuration}"
    .applicationAssemblies = app_assemblies
    .program = "${teamcity_launcher} v2.0 x86 NUnit-2.4.6"
    .testAssembly = "FluentValidation.Tests.dll"
    .excludeAttributes = "System.Runtime.CompilerServices.CompilerGeneratedAttribute"

  with ncover_explorer():
    .toolPath = "${ncover_path}/NCoverExplorer.console.exe"
    .project = "FluentValidation"
    .reportDirectory = "build/coverage"


ast to string sample

ast to string sample

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@786 2c1201b4-01cd-e047-a400-b836ae1fbc61

import Boo.Lang.Compiler
import Boo.Lang.Compiler.Ast
import Boo.Lang.Compiler.Ast.Visitors
import System.IO

def ToString(ast as Node):
	writer=StringWriter()
	BooPrinterVisitor(writer).Visit(ast)
	return writer.ToString()

mie=MethodInvocationExpression(ReferenceExpression("print"))
mie.Arguments.Add(StringLiteralExpression("Hello!"))

print(ToString(mie))

error: pathspec 'examples/ast-to-string.boo' did not match any file(s) known to git


removed unnecessary form instantiation from testcase

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2248 2c1201b4-01cd-e047-a400-b836ae1fbc61


meta programming example

meta programming example

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2701 2c1201b4-01cd-e047-a400-b836ae1fbc61

import Boo.Lang.Compiler.MetaProgramming

dsl = [|

	namespace PetDSL

	import Boo.Lang.Compiler.MetaProgramming
	import Boo.Lang.Compiler.Ast

	class Pet:
		public name = "I need a name"

	[meta] def onCreate(reference as ReferenceExpression, block as BlockExpression):
		return [|
			$reference = $(pascalCase(reference))()
			$(block.Body)
		|]

	def pascalCase(r as ReferenceExpression):
		return ReferenceExpression(Name: pascalCase(r.Name))

	def pascalCase(s as string):
		return s[:1].ToUpper() + s[1:]

|]

app = [|
	import PetDSL

	onCreate pet:
		print pet.name
|]

asm = compile(app, compile(dsl))
asm.EntryPoint.Invoke(null, (null,))

error: pathspec 'examples/meta-programming/PetDSL.boo' did not match any file(s) known to git


document value type simple initialization syntax

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@1791 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
0
100
"""
import System.Drawing from System.Drawing

sz as Size
sz.Height = 100
print sz.Width
print sz.Height

error: pathspec 'tests/testcases/integration/value-types-20.boo' did not match any file(s) known to git


one more test case for virtual method delegate construction

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1662 2c1201b4-01cd-e047-a400-b836ae1fbc61


use rodrigo's suggestion for checking for .net2

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2099 2c1201b4-01cd-e047-a400-b836ae1fbc61


svn automation example

svn automation example

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1285 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
svn change log printer utility.

changelog.boo [FROM-REVISION [TO-REVISION]]

Example:
	changelog.boo PREV HEAD
	changelog.boo 123
	changelog.boo
"""
import System.Xml from System.Xml

class LogEntry:
	Author as string
	Date as date
	Message as string

	def constructor(element as XmlElement):
		Author = element.SelectSingleNode("author/text()").Value
		Date = date.Parse(element.SelectSingleNode("date/text()").Value)
		Message = element.SelectSingleNode("msg/text()").Value

	override def ToString():
		return "${Date} - ${Author}\n${Message}"

	static def Load(fromRevision, toRevision):
		doc = XmlDocument()
		doc.LoadXml(shell("svn", "log --xml -v -r ${fromRevision}:${toRevision}"))
		return array(LogEntry(e) for e in doc.SelectNodes("//logentry"))

if len(argv) > 1:
	fromRevision, toRevision = argv
elif len(argv) > 0:
	fromRevision, = argv
	toRevision = "HEAD"
else:
	fromRevision = toRevision = "HEAD"

entries = LogEntry.Load(fromRevision, toRevision)
print join(entries, "\n")

error: pathspec 'examples/changelog.boo' did not match any file(s) known to git


single element unpacking

single element unpacking

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1247 2c1201b4-01cd-e047-a400-b836ae1fbc61


Added Boo (http://boo.codehaus.org/)

Added Boo (http://boo.codehaus.org/)

error: pathspec 'boo.boo' did not match any file(s) known to git


cannot reproduce static property bug; added testcase

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1217 2c1201b4-01cd-e047-a400-b836ae1fbc61


let macro for declaring global constants

let fortyTwo = Add(21, 21)

namespace Boo.Adt

import Boo.Lang.Compiler
import Boo.Lang.Compiler.Ast
import Boo.PatternMatching

class LetMacro(AbstractAstMacro):
	override def Expand(node as MacroStatement):
		match node.Arguments[0]:
			case BinaryExpression(
					Operator: BinaryOperatorType.Assign,
					Left: ReferenceExpression(Name: name),
					Right: r):
				field = [|
					public static final $name = $r
				|]
				enclosingModule(node).Members.Add(field)

error: pathspec 'extensions/src/Boo.Adt/LetMacro.boo' did not match any file(s) known to git


My[of T].Instance => my(T)

My[of T].Instance => my(T)

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@3408 2c1201b4-01cd-e047-a400-b836ae1fbc61


response file support

response file support

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@3100 2c1201b4-01cd-e047-a400-b836ae1fbc61


added the regression for BOO-603 just in case

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2556 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
secret
"""
class Person:
	[Property(Name)]
	_name as string

	[Property(Labels)]
	_labels as Hash

p1 as duck = Person(Name:"Happy", Labels:{1:'secret', 2:''})
print p1.Labels[1]

error: pathspec 'tests/testcases/regression/BOO-603-1.boo' did not match any file(s) known to git


Const macro

Const macro

namespace BooJs.Lang.Macros

import Boo.Lang.Compiler.Ast

macro global:
""" Avoids the definition of locally scoped variables in order to access
    global values, for example the `window` object.

        global console   # Binds to the duck type by default
        global mystr as string = 'override global value'
"""
    if len(global.Arguments) != 1:
        raise System.ArgumentException('Expected an identifier (ie: global console)')

    node = global.Arguments[0]
    decl = Declaration()
    decl.Annotate('global')
    stmt = DeclarationStatement(Declaration: decl)

    if node.NodeType == NodeType.TryCastExpression:
        decl.Name = (node as TryCastExpression).Target.ToString()
        decl.Type = (node as TryCastExpression).Type
    elif node.NodeType == NodeType.BinaryExpression:
        be = node as BinaryExpression
        if be.Left.NodeType == NodeType.TryCastExpression:
            decl.Name = (be.Left as TryCastExpression).Target.ToString()
            decl.Type = (be.Left as TryCastExpression).Type
        else:
            decl.Name = be.Left.ToString()
        stmt.Initializer = (node as BinaryExpression).Right
    else:
        decl.Name = node.ToString()
        decl.Type = SimpleTypeReference('duck')

    return stmt

error: pathspec 'src/BooJs.Lang/Macros/ConstMacro.boo' did not match any file(s) known to git


avoid BCW0014 on macros that do not use their parent(s) accessor(s)

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@3210 2c1201b4-01cd-e047-a400-b836ae1fbc61


made update-vs2005 script behave mostly the same if running on .Net or mono


one more test for the integration among yield, closures and generator expressions

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1075 2c1201b4-01cd-e047-a400-b836ae1fbc61


test case for code reification of members containing macros


test case to proove BOO-121 is fixed

test case to proove BOO-121 is fixed

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2010 2c1201b4-01cd-e047-a400-b836ae1fbc61


one more event test case just in case...

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1239 2c1201b4-01cd-e047-a400-b836ae1fbc61


BOO-835: DSL-friendly method syntax, Let's give it a testcase.

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2923 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
<html>
<body>
Hello, world!
</body>
</html>
"""

callable Block()

def blockTag(tagName as string, block as Block):
	print "<${tagName}>"
	block()
	print "</${tagName}>"

def html(block as Block):
	blockTag "html", block

def body(block as Block):
	blockTag "body", block

def text(s as string):
	print s

html:
	body:
		text "Hello, world!"

error: pathspec 'tests/testcases/regression/BOO-835-1.boo' did not match any file(s) known to git


booxg, booxg codebase unification

booxg, booxg codebase unification

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@781 2c1201b4-01cd-e047-a400-b836ae1fbc61


Script to generate test case from fixtures directory

import System
import System.IO

def PascalCase(name as string):
    return name[:1].ToUpper() + name[1:]

def IntegrationTestFixtureName(dir as string):
    baseName = join(PascalCase(part) for part in /-/.Split(Path.GetFileName(dir)), '')
    return "${baseName}IntegrationTestFixture"

if not len(argv):
  print "Usage: booi script.boo -- path/to/fixtures/directory"
  return

path = Path.GetFullPath(argv[1])

name = Path.GetFileNameWithoutExtension(path)
name = name[:1].ToUpper() + name[1:]

print '"""'
print "  Automatically generated!"
print "  Fixture test cases from $path"
print '"""'
print ''
print 'import NUnit.Framework'
print ''
print '[TestFixture]'
print "class FixtureTestCasesFor$name:"
print ''

for fname in Directory.GetFiles(path):
  continue unless fname.EndsWith(".boo")

  name = Path.GetFileNameWithoutExtension(fname)
  name = name.Replace('-', '_')

  print "  [Test]"
  print "  def test_$name():"
  print "    FixtureRunner.run('$fname')"
  print ""

error: pathspec 'scripts/generate-fixture-testcases.boo' did not match any file(s) known to git


tcp echo server example

tcp echo server example

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@322 2c1201b4-01cd-e047-a400-b836ae1fbc61


ast to string sample

ast to string sample

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@786 2c1201b4-01cd-e047-a400-b836ae1fbc61


document value type simple initialization syntax

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@1791 2c1201b4-01cd-e047-a400-b836ae1fbc61


one more test case

one more test case

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2725 2c1201b4-01cd-e047-a400-b836ae1fbc61


BOO-549 test case

BOO-549 test case

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@1979 2c1201b4-01cd-e047-a400-b836ae1fbc61


field order test case

field order test case

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1693 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
public class B(System.Object):

	public def constructor():
		super()
		self.___initializer()
		System.Console.WriteLine(self.a)
		System.Console.WriteLine(self.b)

	protected b as System.String

	protected a as System.String

	def ___initializer() as System.Void:
		self.b = 'foo'
		self.a = 'bar'
"""
class B:
	def constructor():
		print a
		print b

	b = "foo"
	a = "bar"

error: pathspec 'tests/testcases/semantics/fields-7.boo' did not match any file(s) known to git


BOO-231 patch by Bill Wood

BOO-231 patch by Bill Wood

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1353 2c1201b4-01cd-e047-a400-b836ae1fbc61


BOO-770 test case

BOO-770 test case

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2758 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
-1
"""
class Bug:
	[property(Id)] _id = 0

	static def Load():
		return Bug(Id: -1)

print Bug.Load().Id

error: pathspec 'tests/testcases/regression/BOO-770-1.boo' did not match any file(s) known to git


closures inside generators

closures inside generators

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@889 2c1201b4-01cd-e047-a400-b836ae1fbc61

import NUnit.Framework

closures = <return i> for i in range(3)

for expected, closure as callable in zip(range(3), closures):
    Assert.AreEqual(expected, closure(), "for variables are not shareable")

error: pathspec 'tests/testcases/integration/closures-22.boo' did not match any file(s) known to git


new trace macro for debug messages

new trace macro for debug messages

namespace BooJs.Lang.Macros

import Boo.Lang.Compiler(CompilerContext)
import Boo.Lang.Compiler.Ast(StringLiteralExpression)

macro trace:
    return unless CompilerContext.Current.Parameters.Debug

    mie = [| BooJs.Lang.Builtins.print() |]
    mie.Arguments = trace.Arguments

    prefix = '{0}:{1}' % (trace.LexicalInfo.FileName, trace.LexicalInfo.Line)
    mie.Arguments.Insert(0, StringLiteralExpression(prefix))
    yield mie

error: pathspec 'src/BooJs.Lang/Macros/TraceMacro.boo' did not match any file(s) known to git


BOO-327 test case

BOO-327 test case

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@1841 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
2 3 4
2 3 4
"""
import System.Collections

def Fetch(n as int, seq):
    i = 0
    for val in seq:
        yield val
        break if ++i == n

class Test:
    static def Arr(n as int, list):
        return array(double, Fetch(n, list))

def Arr(n as int, list):
    return array(double, Fetch(n, list))

a,b,c = Test.Arr(3, [1, 2, 3, 4, 5, 6])
print a+1, b+1, c+1   # will break if a etc aren't numbers!
d,e,f = Arr(3, [1, 2, 3, 4, 5, 6])
print d+1, e+1, f+1

error: pathspec 'tests/testcases/regression/BOO-327-1.boo' did not match any file(s) known to git


BOO-327 test case

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/BillHally/boo.git/'


wrapLines example

wrapLines example

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@818 2c1201b4-01cd-e047-a400-b836ae1fbc61


test case for BOO-369 bug

test case for BOO-369 bug

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1708 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
42
32
"""
callable handler(a as int) as int

class Action:
	cb as handler
	def constructor(callback as handler):
		cb = callback

class A:
	a as Action
	[getter(Go)]
	ac = Action() def(para):
		newa = A(32)
	def constructor(p):
		a = ac
		print p

A(42).Go()

error: pathspec 'tests/testcases/regression/BOO-369-1.boo' did not match any file(s) known to git


test case for BOO-759

test case for BOO-759

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@3235 2c1201b4-01cd-e047-a400-b836ae1fbc61


Create test.boo

Create test.boo

error: pathspec 'test.boo' did not match any file(s) known to git


codedom typo for sealed delegates

codedom typo for sealed delegates

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2082 2c1201b4-01cd-e047-a400-b836ae1fbc61


repr implementation based on a provided Representer strategy

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1138 2c1201b4-01cd-e047-a400-b836ae1fbc61


unused local in AbstractBooTask

unused local in AbstractBooTask

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1276 2c1201b4-01cd-e047-a400-b836ae1fbc61


minor refactoring

minor refactoring

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@3464 2c1201b4-01cd-e047-a400-b836ae1fbc61


basic save functionality

basic save functionality

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@768 2c1201b4-01cd-e047-a400-b836ae1fbc61


coroutine simulation with generators

coroutine simulation with generators

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1499 2c1201b4-01cd-e047-a400-b836ae1fbc61

class XPer:

	def Test():
		while true:
			print "testing"
			yield null

	def Code():
		while true:
			print "coding"
			yield null

	def Refactor():
		while true:
			print "refactoring"
			yield null

	def Iterate(times as int):
		assert times > 0

		test = Test().GetEnumerator()
		code = Code().GetEnumerator()
		refactor = Refactor().GetEnumerator()
		while times > 0:
			test.MoveNext()
			code.MoveNext()
			refactor.MoveNext()
			test.MoveNext()
			--times

XPer().Iterate(5)

error: pathspec 'examples/coroutines.boo' did not match any file(s) known to git


multiline member references test case

multiline member references test case

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2370 2c1201b4-01cd-e047-a400-b836ae1fbc61


include parser test

include parser test


test case for BOO-102 issue

test case for BOO-102 issue

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@897 2c1201b4-01cd-e047-a400-b836ae1fbc61


booi will try to find the assemblies in the current folder first

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@339 2c1201b4-01cd-e047-a400-b836ae1fbc61


sincos example

sincos example

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@733 2c1201b4-01cd-e047-a400-b836ae1fbc61


Mono.GetOptions example

Mono.GetOptions example

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@947 2c1201b4-01cd-e047-a400-b836ae1fbc61

import Mono.GetOptions from Mono.GetOptions

class CommandLineOptions(Options):

	def constructor(argv):
		ProcessArgs(argv)

	[Option("thumbnail width", "width")]
	public Width = 70

	[Option("thumbnail height", "height")]
	public Height = 70

	[Option("output file", "output")]
	public OutputFileName = ""

	[Option("input file", "input")]
	public InputFileName = ""

	[Option("encoding quality level (1-100), default is 75", "encoding-quality")]
	public EncodingQuality = 75L

	IsValid as bool:
		get:
			return (0 == len(RemainingArguments) and
					len(OutputFileName) > 0 and
					len(InputFileName) > 0 and
					Width > 0 and
					Height > 0)

options = CommandLineOptions(argv)
if options.IsValid:
	for field in typeof(CommandLineOptions).GetFields():
		print("${field.Name}: ${field.GetValue(options)}")
else:
	options.DoHelp()

error: pathspec 'examples/GetOptions.boo' did not match any file(s) known to git


meta programming example

meta programming example

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2701 2c1201b4-01cd-e047-a400-b836ae1fbc61


fixed missing base type

fixed missing base type

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2759 2c1201b4-01cd-e047-a400-b836ae1fbc61


added class with base class testcase

added class with base class testcase

"""
test
"""

jar = [|
	import java.lang

	class Base:
		pass
|]

test = [|
	import java.lang

	class Foo(Base):
		pass

	print "test"
|]

runTestWithJar(test, jar)

error: pathspec 'boojay/tests/jar_integration/Classes.boo' did not match any file(s) known to git


custom scheduler example : lottery scheduler

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2825 2c1201b4-01cd-e047-a400-b836ae1fbc61


Changed testcase to match updated error string.

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2747 2c1201b4-01cd-e047-a400-b836ae1fbc61


Ignoring false failing tests.
The probable issue is timing with regard to the file watcher.

git-svn-id: bab0c2de90ee11a20376049c2cdee62584491f34@1996 73e77b4c-caa6-f847-a29a-24ab75ae54b6

// Copyright 2004-2005 Castle Project - http://www.castleproject.org/
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
namespace Castle.MonoRail.Views.Brail.Tests

import System
import System.IO
import NUnit.Framework
import Castle.MonoRail.TestSupport

[TestFixture]
class BrailBasicFunctionality(AbstractMRTestCase):

	[Test]
	def AppPath():
		DoGet("apppath/index.rails")
		AssertReplyEqualTo("Current apppath is ")

	[Test, Ignore("Sometimes fail, but the functionality is working.")]
	def AppPathChangeOnTheFly():
		script = Path.Combine(GetPhysicalDir(),"""Views\AppPath\Index.boo""")
		newContent = "new content"
		using read = File.OpenText(script):
			old = read.ReadToEnd()
		using write = File.CreateText(script):
			write.Write(newContent)
		# Wait half a sec so Brail could pick up that a change in the file occured.
		System.Threading.Thread.Sleep(500)
		try:
			DoGet("apppath/index.rails")
			AssertReplyEqualTo(newContent)
		ensure:
			using write = File.CreateText(script):
				write.Write(old)

	[Test]
	def CommonScripts():
		DoGet("home/hellofromcommon.rails")
		expected = "Hello, Ayende"
		AssertReplyEqualTo(expected)

	[Test]
	def Nullables():
		DoGet("home/nullables.rails")
		expected = "\r\nfoo"
		AssertReplyEqualTo(expected)

	[Test]
	def Empty():
		DoGet("home/Empty.rails")
		expected = ""
		AssertReplyEqualTo(expected)

	[Test, Ignore("Sometimes fail, but the functionality is working.")]
	def CommonScriptsChangeOnTheFly():
		common = Path.Combine(GetPhysicalDir(),"""Views\CommonScripts\Hello.boo""")
		using read = File.OpenText(common ):
			old = read.ReadToEnd()
		new = """
def SayHello(name as string):
	return "Hello, \${name}! Modified!"
end"""
		using write = File.CreateText(common ):
			write.Write(new)
		expected = "Hello, Ayende! Modified!"
		# Have to wait for the common scripts recompilation otherwise you get random test failure since the request
		# sometimes gets there faster you can recompile and it gets the old version.
		System.Threading.Thread.Sleep(500)
		try:
			DoGet("home/hellofromcommon.rails")
			AssertReplyEqualTo(expected)
		ensure:
			using write = File.CreateText(common ):
				write.Write(old)
		#Have to wait again to make sure that the second recompilation happened, since otherwise a second test
		# might get the modified version.
		System.Threading.Thread.Sleep(500)

	[Test]
	def PreProcessor():
		DoGet("home/preprocessor.rails")
		expected = """

<title>AYENDE</title>

0

1

2

"""
		AssertReplyEqualTo(expected)

// Copyright 2004-2005 Castle Project - http://www.castleproject.org/
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
namespace Castle.MonoRail.Views.Brail.Tests

import System
import System.IO
import NUnit.Framework
import Castle.MonoRail.TestSupport

[TestFixture]
class BrailBasicFunctionality(AbstractMRTestCase):

	[Test]
	def AppPath():
		DoGet("apppath/index.rails")
		AssertReplyEqualTo("Current apppath is ")

	[Test]
	def AppPathChangeOnTheFly():
		script = Path.Combine(GetPhysicalDir(),"""Views\AppPath\Index.boo""")
		newContent = "new content"
		using read = File.OpenText(script):
			old = read.ReadToEnd()
		using write = File.CreateText(script):
			write.Write(newContent)
		# Wait half a sec so Brail could pick up that a change in the file occured.
		System.Threading.Thread.Sleep(500)
		try:
			DoGet("apppath/index.rails")
			AssertReplyEqualTo(newContent)
		ensure:
			using write = File.CreateText(script):
				write.Write(old)

	[Test]
	def CommonScripts():
		DoGet("home/hellofromcommon.rails")
		expected = "Hello, Ayende"
		AssertReplyEqualTo(expected)

	[Test]
	def Nullables():
		DoGet("home/nullables.rails")
		expected = "\r\nfoo"
		AssertReplyEqualTo(expected)

	[Test]
	def Empty():
		DoGet("home/Empty.rails")
		expected = ""
		AssertReplyEqualTo(expected)

	[Test]
	def CommonScriptsChangeOnTheFly():
		common = Path.Combine(GetPhysicalDir(),"""Views\CommonScripts\Hello.boo""")
		using read = File.OpenText(common ):
			old = read.ReadToEnd()
		new = """
def SayHello(name as string):
	return "Hello, \${name}! Modified!"
end"""
		using write = File.CreateText(common ):
			write.Write(new)
		expected = "Hello, Ayende! Modified!"
		# Have to wait for the common scripts recompilation otherwise you get random test failure since the request
		# sometimes gets there faster you can recompile and it gets the old version.
		System.Threading.Thread.Sleep(500)
		try:
			DoGet("home/hellofromcommon.rails")
			AssertReplyEqualTo(expected)
		ensure:
			using write = File.CreateText(common ):
				write.Write(old)
		#Have to wait again to make sure that the second recompilation happened, since otherwise a second test
		# might get the modified version.
		System.Threading.Thread.Sleep(500)

	[Test]
	def PreProcessor():
		DoGet("home/preprocessor.rails")
		expected = """

<title>AYENDE</title>

0

1

2

"""
		AssertReplyEqualTo(expected)


Adding trivial boo example for listing files in current directory.

import System.IO

for file in Directory.GetFiles ("./", "*"):
  print file

error: pathspec 'boo/files/listing.boo' did not match any file(s) known to git


gtk example

gtk example

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@726 2c1201b4-01cd-e047-a400-b836ae1fbc61

import System
import Gtk

def button_Clicked(sender, args as EventArgs):
	print("button clicked!")

def window_Delete(sender, args as DeleteEventArgs):
	Application.Quit()
	args.RetVal = true

Application.Init()

window = Window("Button Tester",
				DefaultWidth:  200,
				DefaultHeight: 150,
				DeleteEvent: window_Delete)

window.Add(Button("Click Me!", Clicked: button_Clicked))
window.ShowAll()

Application.Run()

error: pathspec 'examples/gtk.boo' did not match any file(s) known to git


whichserver example

whichserver example

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@730 2c1201b4-01cd-e047-a400-b836ae1fbc61


test case for BOO-102 issue

"""
BCE0024-2.boo(9,5): BCE0024: The type 'Foo' does not have a visible constructor that matches the argument list '()'.
"""
class Foo:
	def constructor(item):
		pass

class Bar:
	def constructor():
		pass

error: pathspec 'tests/testcases/errors/BCE0024-2.boo' did not match any file(s) known to git


BOO-679

BOO-679

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2266 2c1201b4-01cd-e047-a400-b836ae1fbc61


duck typing examples

duck typing examples

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1231 2c1201b4-01cd-e047-a400-b836ae1fbc61

#region license
// Copyright (c) 2003, 2004, Rodrigo B. de Oliveira (rbo@acm.org)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//     * Neither the name of Rodrigo B. de Oliveira nor the names of its
//     contributors may be used to endorse or promote products derived from this
//     software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion

"""
This example shows how to use IQuackFu.QuackGet to provide
transparent access to xml elements.
"""

import System
import System.Xml from System.Xml

class XmlObject(IQuackFu):

	_element as XmlElement

	def constructor(element as XmlElement):
		_element = element

	def constructor(text as string):
		doc = XmlDocument()
		doc.LoadXml(text)
		_element = doc.DocumentElement

	def QuackInvoke(name as string, args as (object)) as object:
		pass

	def QuackSet(name as string, value) as object:
		pass

	def QuackGet(name as string) as object:
		element = _element.SelectSingleNode(name)
		return XmlObject(element) if element is not null

	override def ToString():
		return _element.InnerText

xml = """
<Person>
	<FirstName>John</FirstName>
	<LastName>Cleese</LastName>
</Person>
"""

person as duck = XmlObject(xml)
print person.FirstName
print person.LastName

error: pathspec 'examples/duck-typing/XmlObject.boo' did not match any file(s) known to git


don't apply license to AssemblyInfo.cs

don't apply license to AssemblyInfo.cs

git-svn-id: d6bffa57a36fe0f3c7d18ef52cc0c4d4ff653ca6@201 66c3f25c-543c-0410-ae2e-6f2ca0bd8c61

#region license
// Copyright (c) 2004, Rodrigo B. de Oliveira (rbo@acm.org)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//     * Neither the name of Rodrigo B. de Oliveira nor the names of its
//     contributors may be used to endorse or promote products derived from this
//     software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
"""
Makes sure that every file in the fileset starts
with the license notice.
"""
import System.Diagnostics
import System.Collections.Generic
import System.IO

class InsertLicenseTask:

	_license as string

	License:
		get:
			return _license
		set:
			_license = value

	def ExecuteTask():
		licenseText = File.ReadAllText(_license)
		for fname in GetFiles("."):
			InsertLicense(fname, licenseText) if GetFirstLine(fname) != "#region license"

	def InsertLicense(fname as string, license as string):
		print "Processing: ${fname}"
		contents = File.ReadAllText(fname)
		using writer=StreamWriter(fname, false, System.Text.Encoding.UTF8):
			writer.WriteLine(license)
			writer.WriteLine()
			writer.Write(contents)

	def GetFirstLine(fname as string):
		using f=File.OpenText(fname):
			return f.ReadLine()

	def GetFiles(dir as string) as IEnumerable of string:
			exts = ("*.cs", "*.boo")
			for ext in exts:
				for file in Directory.GetFiles(dir, ext):
					yield file if not file.EndsWith("AssemblyInfo.cs")

			for subDir in Directory.GetDirectories(dir):
				for fname as string in GetFiles(subDir):
					yield fname

InsertLicenseTask(License: "notice.txt").ExecuteTask()

#region license
// Copyright (c) 2004, Rodrigo B. de Oliveira (rbo@acm.org)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//     * Neither the name of Rodrigo B. de Oliveira nor the names of its
//     contributors may be used to endorse or promote products derived from this
//     software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
"""
Makes sure that every file in the fileset starts
with the license notice.
"""
import System.Diagnostics
import System.Collections.Generic
import System.IO

class InsertLicenseTask:

	_license as string

	License:
		get:
			return _license
		set:
			_license = value

	def ExecuteTask():
		licenseText = File.ReadAllText(_license)
		for fname in GetFiles("."):
			InsertLicense(fname, licenseText) if GetFirstLine(fname) != "#region license"

	def InsertLicense(fname as string, license as string):
		print "Processing: ${fname}"
		contents = File.ReadAllText(fname)
		using writer=StreamWriter(fname, false, System.Text.Encoding.UTF8):
			writer.WriteLine(license)
			writer.WriteLine()
			writer.Write(contents)

	def GetFirstLine(fname as string):
		using f=File.OpenText(fname):
			return f.ReadLine()

	def GetFiles(dir as string) as IEnumerable of string:
			exts = ("*.cs", "*.boo")
			for ext in exts:
				for file in Directory.GetFiles(dir, ext):
					yield file

			for subDir in Directory.GetDirectories(dir):
				for fname as string in GetFiles(subDir):
					yield fname

InsertLicenseTask(License: "notice.txt").ExecuteTask()


better test case for array equality

better test case for array equality

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@924 2c1201b4-01cd-e047-a400-b836ae1fbc61


better code organization

better code organization

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@340 2c1201b4-01cd-e047-a400-b836ae1fbc61


test case for complex bug involving nullables and generators


macro test cases

macro test cases

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1118 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
spam
1 2 3

eggs 42
"""
print "spam"
print 1, 2, 3
print
print "eggs", 42

error: pathspec 'tests/testcases/macros/print-1.boo' did not match any file(s) known to git


booish2: autocompletion displays nicely on win32 + delete key working

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2507 2c1201b4-01cd-e047-a400-b836ae1fbc61


macro test cases


one more test for the integration among yield, closures and generator expressions

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1075 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
0
1
0, 8, 16, 24
"""
class Generator:

	[property(B)]
	_b = 5

	def run(begin as int, end as int):
		a = 0
		yield { return a }
		yield { --begin; return ++a }
		yield { a = _b; return { return (a+_b)*i for i in range(begin, end) } }
		assert 5 == a

g = Generator()
for f in g.run(1, 4):
	item = f()
	if item isa callable:
		g.B = 3
		print(join(cast(callable, item)(), ", "))
	else:
		print(item)

error: pathspec 'tests/testcases/integration/yield-12.boo' did not match any file(s) known to git


typo fix

typo fix

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2100 2c1201b4-01cd-e047-a400-b836ae1fbc61


compiler api test

compiler api test

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1039 2c1201b4-01cd-e047-a400-b836ae1fbc61


tray icon now displays the current activity

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1206 2c1201b4-01cd-e047-a400-b836ae1fbc61


quick fix for [once] to work with multiple properties in the same class

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@3493 2c1201b4-01cd-e047-a400-b836ae1fbc61


one more event test case just in case...

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1239 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
Idle called
"""
import System

class Application:

	static event Idle as EventHandler

	static def Run(o):
		Idle(null, EventArgs.Empty)

class Test:

	_idleHandler as EventHandler = Application_Idle

	def constructor():
		Application.Idle += _idleHandler

	def Application_Idle():
		Application.Idle -= _idleHandler
		print "Idle called"

t = Test()
Application.Run(t)
Application.Run(t)

error: pathspec 'tests/testcases/integration/events-7.boo' did not match any file(s) known to git


don't run System.Windows.Forms dependent regression test under mono


pipeline example

pipeline example

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1738 2c1201b4-01cd-e047-a400-b836ae1fbc61


splice works for statements and blocks too now; Added Statement.ToBlock to make it easy to get a block; TraceMethodCallsAttribute is now making more use the meta-programming support

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2590 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
def foo():
	print 'before'
	try:
		print('Hello, world')
	ensure:
		print 'after'
"""
method = [|
	def foo():
		print("Hello, world")
|]

method.Body = [|
	print "before"
	try:
		$(method.Body)
	ensure:
		print "after"
|]

print method.ToCodeString()

error: pathspec 'tests/testcases/integration/meta-programming/splicing-4.boo' did not match any file(s) known to git


print a new line at end

print a new line at end

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1338 2c1201b4-01cd-e047-a400-b836ae1fbc61


multimethods example for GB

multimethods example for GB

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2034 2c1201b4-01cd-e047-a400-b836ae1fbc61

#region license
// Copyright (c) 2003, 2004, 2005 Rodrigo B. de Oliveira (rbo@acm.org)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//     * Neither the name of Rodrigo B. de Oliveira nor the names of its
//     contributors may be used to endorse or promote products derived from this
//     software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion

class GameObject:
	pass

class Ship(GameObject):
	pass

class Missile(GameObject):
	pass

class CollisionHandler:
"""
Takes advantage of runtime dispatching on all arguments
to handle collisions between concrete game objects.
"""
	def handle(ship as Ship, missile as Missile):
		print "a ship collided with a missile"

	def handle(missile as Missile, ship as Ship):
		print "a missile collided with a ship"

	def handle(missile1 as Missile, missile2 as Missile):
		print "a missile collided with another missile"

	def handle(ship1 as Ship, ship2 as Ship):
		print "a ship collided with another ship"

def gameLoop():

	objects = [Ship(), Missile(), Missile(), Ship(), Missile()]

	random = System.Random()
	select = def:
		return objects[random.Next(len(objects))]

	# duck enables runtime dispatch
	handler as duck = CollisionHandler()
	while true:
		handler.handle(select(), select())
		yield

for _ in zip(range(10), gameLoop()):
	pass

error: pathspec 'examples/duck-typing/multimethods.boo' did not match any file(s) known to git


Object construction example

Object construction example

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@931 2c1201b4-01cd-e047-a400-b836ae1fbc61