% bug demo script
%

clear all;

% The following behavior is different from Matlab
% It seems to be inconsistent in Octave (and in the first case also in Matlab)

% It's two functions so it should probably be two bugs?


% ----- in base class:

demoMyClass = myClass();

% varnames():
% Matlab reveals only public properties (for me this seems ok)
% Octave reveals both private and public (not what I would expect even if I get a warning)
varnames = fieldnames(demoMyClass)

% isprop():
% Matlab reveals both private and public properties (for me this is WTF Matlab)
% Octave reveals none at all (this I would consider a Bug)
% the expected behavior is to reveal public, at least for me!
isprop(demoMyClass, 'publicProperty')
isprop(demoMyClass, 'privateProperty')


% ----- in derived class:

demoMyDerivedClass = myDerivedClass();

% varnames():
% Matlab reveals only public properties (for me this seems ok)
% Octave reveals both private and public (again not what I would expect)
varnames = fieldnames(demoMyDerivedClass)

% isprop():
% Matlab reveals only public properties (for me this seems ok)
% Octave reveals none at all (again I would consider this a Bug)
isprop(demoMyDerivedClass, 'publicProperty')
isprop(demoMyDerivedClass, 'privateProperty')


% output Matlab 2019b (on windows 10):
%{

myClass constructor
varnames =
  1×1 cell array
    {'publicProperty'}
ans =
  logical
   1
ans =
  logical
   1
myClass constructor
myDerivedClass constructor
varnames =
  1×1 cell array
    {'publicProperty'}
ans =
  logical
   1
ans =
  logical
   0

%}



% output Octave 5.2.0, x86_64-w64-mingw32 (on windows 10)
%{
                                                                                                 
myClass constructor
warning: struct: converting a classdef object into a struct overrides the access restrictions defined for properties. All properties are returned, including private and protected ones.
warning: called from
    fieldnames at line 47 column 11
    demoScript at line 19 column 10
varnames =
{
  [1,1] = privateProperty
  [2,1] = publicProperty
}

ans = 0
ans = 0
myClass constructor
myDerivedClass constructor
warning: struct: converting a classdef object into a struct overrides the access restrictions defined for properties. All properties are returned, including private and protected ones.
warning: called from
    fieldnames at line 47 column 11
    demoScript at line 35 column 10
varnames =
{
  [1,1] = privateProperty
  [2,1] = publicProperty
}

ans = 0
ans = 0

%}

