view test/classes/@CPrecedenceTester3/CPrecedenceTester3.m @ 16070:e603ce23f20c

Fix and improve functions related to class precedence (bug #38290) * libinterp/octave-value/ov-class.cc(inferiorto): Use only one call to set_class_relationship() and properly use the returned value. Rewrite for clarity (fewer braces, shorter lines). (superiorto): Rewrite similarly to inferiorto() for clarity. * libinterp/interpfcn/symtab.cc(symbol_table::set_class_relationship): Reduce code redundancy using a call to is_superiorto(). Add a comment to make it clear that a new entry in the precedence table is created if sup_class is not already there. (symbol_table::is_superiorto): Rewrite more concisely. Add a comment. * test/classes/@CPrecedenceTester1, test/classes/@CPrecedenceTester2, test/classes/@CPrecedenceTester3: New classes for precedence tests. * test/classes/@Snork/tattack.m: New method for precedence tests. * test/classes/classes.tst: Add precedence tests.
author Julien Bect <julien.bect@supelec.fr>
date Tue, 29 Jan 2013 17:55:53 +0100
parents
children b1283d4c06c2
line wrap: on
line source

function x = CPrecedenceTester3(flag)

  x = struct('useless_data', pi^3);
  x = class(x, 'CPrecedenceTester3');

  switch flag,
    case 1, % CPrecedencetester3 > Snork
      superiorto('Snork');
    case 2, % CPrecedencetester3 < Snork
      inferiorto('Snork');
    otherwise,
      error('Incorrect value for argument flag: %d', flag);
  end

end