Changeset 331 for EcnlProtoTool/trunk/mruby-1.3.0/test/t/class.rb
- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- Location:
- EcnlProtoTool/trunk/mruby-1.3.0
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/mruby-1.3.0/test/t/class.rb
r321 r331 385 385 end 386 386 387 assert('class variable definition in singleton_class') do 388 class ClassVariableDefinitionInSingletonTest 389 class << self 390 @@class_variable = "value" 391 end 392 def class_variable 393 @@class_variable 394 end 395 end 396 397 assert_equal("value", ClassVariableDefinitionInSingletonTest.new.class_variable) 398 end 399 400 assert('class variable in module and class << self style class method') do 401 module ClassVariableInModuleTest 402 @@class_variable = "value" 403 class << self 404 def class_variable 405 @@class_variable 406 end 407 end 408 end 409 410 assert_equal("value", ClassVariableInModuleTest.class_variable) 411 end 412 413 assert('child class/module defined in singleton class get parent constant') do 414 actual = module GetParentConstantTest 415 EXPECT = "value" 416 class << self 417 class CHILD 418 class << self 419 EXPECT 420 end 421 end 422 end 423 end 424 assert_equal("value", actual) 425 end 426 427 assert('overriding class variable with a module (#3235)') do 428 module ModuleWithCVar 429 @@class_variable = 1 430 end 431 class CVarOverrideTest 432 @@class_variable = 2 433 include ModuleWithCVar 434 435 assert_equal(1, @@class_variable) 436 end 437 end 438 387 439 assert('class with non-class/module outer raises TypeError') do 388 440 assert_raise(TypeError) { class 0::C1; end } 389 441 assert_raise(TypeError) { class []::C2; end } 390 442 end 443 444 assert("remove_method doesn't segfault if the passed in argument isn't a symbol") do 445 klass = Class.new 446 assert_raise(TypeError) { klass.remove_method nil } 447 assert_raise(TypeError) { klass.remove_method 123 } 448 assert_raise(TypeError) { klass.remove_method 1.23 } 449 assert_raise(NameError) { klass.remove_method "hello" } 450 assert_raise(TypeError) { klass.remove_method Class.new } 451 end
Note:
See TracChangeset
for help on using the changeset viewer.